This is not so much a “how-to”, but more of a “is this how-to?”, I post it here mainly to invite comment and expose my ignorance about the much cleaner method that probably exists.
OK, first my use case – in a skin I am building the title of the current level 0 node is always displayed as a section heading e.g. If you are viewing the page “eggs”, a few levels down and the breadcrumb trail reads home -> foo -> bar -> eggs, “foo” is displayed as a banner heading, so wherever you are in the site you know what main section you are in.
so I have created a skin script called getLevelZeroTitle that has approximately this in it (with try/except statements, and a list of id’s to ignore to handle errors):-
current_level0_path = ‘/’.join(context.getPhysicalPath()[:3])
section_id = context.getPhysicalPath()
current_level0_title = context.portal_catalog(path=current_level0_path).Title
Is this the way forward or is there something “built in” to handle this?