Ralf,

Brilliant! Your advice is, once again, tremendously helpful.

Here's my final version, for anybody who may come later and find it
valuable:

-----
<jsp:directive.page import="info.magnolia.cms.util.Resource" />

<jsp:directive.page import="info.magnolia.cms.core.Content" />
<jsp:directive.page import="java.util.Iterator" />  



<jsp:scriptlet>
    <![CDATA[
    Iterator it = Resource.getActivePage(request).getAncestors().iterator();
    String title = null;
    while ( it.hasNext() ){
        Content c = (Content) it.next() ;
        if ( c != null && c.getNodeData("title").getString() != "" )
            title = c.getNodeData("title").getString();
    }
    if ( title == null ) {
        title = Resource.getActivePage( request ).getNodeData( "title"
).getString();
    }
    out.println( title );
    ]]>
</jsp:scriptlet>
-----

I made a couple of changes to handle deeper than one level nesting
(/technology-resources/contact/administration) as well as home pages
(/technology-resources). It's now doing exactly what I'd wanted.

Thanks again, Ralf!

Sean


On 7/20/06 12:08 AM, "Ralf Hirning" <[email protected]> wrote:

> Hi Sean,
> 
> top level means top level within this page, not within the website
> hierarchy.
> 
> You can browse the website hierarchy using Magnolia API from within your
> template jsp. So you get the top level title with this jsp scriptlet:
> 
> Iterator it = Resource.getActivePage(request).getAncestors().iterator();
> Content c = (Content) it.next();
> String title = c.getNodeData("title").getString();
> 
> Ralf


----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to