Of course to get all ancestors, you would place it in a macro and recursively 
iterate up.
But of course you're right, having it in STKUtil would be nice.

- C

On Feb 28, 2011, at 10:13 AM, Christian Ringele wrote:

> Hi Wil,
> 
> You have the freemarker built in '?parent' and you have the object 'page' 
> which reflects the page node when you're operating on a paragraph level.
> So (on a page node) content?parent should directly lead you to your ancestor.
> 
> On a paragraph you could do 'page?parent'
> 
> - C
> 
> 
> On Feb 25, 2011, at 10:44 AM, Will Scheidegger wrote:
> 
>> Thanks for the feedback, everyone!
>> 
>> I'm glad that my code seems to be acceptable. However I guess I should open 
>> a JIRA issue asking for a "getAncestor" method in STKUtils... 
>> 
>> -will
>> 
>> On 25.02.2011, at 10:31, Unger, Richard wrote:
>> 
>>> Hi Will!
>>> 
>>> I can confirm that we are doing similar „tricks“ to handle things like 
>>> sidebar content.
>>>  
>>> It doesn’t seem like such a bad solution to me, and the code does not seem 
>>> so “dirty” to me either.
>>>  
>>> On a similar note, I also wrote some macro/model code to do the function 
>>> “inherit first” à since stk.inheritContent() is an “inherit all” type 
>>> function, where all the content named “iconLinks” (to use your example) 
>>> from all ancestor nodes of content is gathered in a collection.
>>> We found we wanted to walk up the tree to find the first instance of 
>>> “iconLinks” and then stop there, effectively allowing us to make settings 
>>> at top level pages, but ‘override’ them at deeper level pages if needed.
>>>  
>>> Regards from Vienna,
>>>  
>>> Richard
>>>  
>>>  
>>> Von: [email protected] 
>>> [mailto:[email protected]] Im Auftrag von Will Scheidegger
>>> Gesendet: Donnerstag, 24. Februar 2011 23:26
>>> An: Magnolia User-List
>>> Betreff: Re: [magnolia-user] STK question: inherited singelton link list 
>>> like meta nav?
>>>  
>>> Answering my own question... something like this below did the job. But I 
>>> don't think it would win a price in a code beauty contest...
>>>  
>>> [#assign cms=JspTaglibs["cms-taglib"]]
>>> 
>>> <ul id="icon_links">
>>>   [#assign iconLinksModel = stk.inheritContent(content, "iconLinks") /]
>>>   [#if iconLinksModel.exists]
>>>     [@cms.contentNodeIterator contentNode=iconLinksModel.content!]
>>>         [@cms.includeTemplate /]
>>>     [/@cms.contentNodeIterator]
>>>   [/#if]
>>>   [#if mgnl.editMode && content.@level == 1]
>>>       <li class="icon_link">[@cms.newBar 
>>> contentNodeCollectionName="iconLinks" newLabel="Neues Icon-Link" 
>>> paragraph="schweizmobilcardExternalImageLink,schweizmobilcardInternalImageLink"
>>>  /]</li>
>>>   [/#if]
>>> </ul>
>>>  
>>> On 24.02.2011, at 18:16, Will Scheidegger wrote:
>>> 
>>> 
>>> 
>>> Dear Magnolians
>>> 
>>> We need to add a list of "sponsor" (icon, link, name) on each page. It 
>>> pretty much boils down to the same functionality the meta navigation 
>>> offers. But the meta navigation uses special methods the model provides. 
>>> 
>>> Now of course I could extend STKTemplateModel and copy the meta navigation 
>>> methods. But can I do the same without modifying the model?
>>> 
>>> Whatever I have tried so far has failed miserably. I've done this in JSP 
>>> templates, but somehow Freemarker is giving me a hard time... for instance: 
>>> How can I get the ancestor node at level 1? ${content.getAncestor(1)} does 
>>> not work because of the Magnolia Freemarker "features"...
>>> 
>>> Thanks for any pointers!
>>> 
>>> -will
>>> 
>>> 
>>> ----------------------------------------------------------------
>>> For list details see
>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>> To unsubscribe, E-mail to: <[email protected]>
>>> ----------------------------------------------------------------
>>> 
>>>  
>>>  
>>> 
>>> ----------------------------------------------------------------
>>> For list details see
>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>> To unsubscribe, E-mail to: <[email protected]>
>>> ----------------------------------------------------------------
>>> 
>>> 
>>> ----------------------------------------------------------------
>>> For list details see
>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>> To unsubscribe, E-mail to: <[email protected]>
>>> ----------------------------------------------------------------
>> 
>> 
>> 
>> ----------------------------------------------------------------
>> For list details see
>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>> To unsubscribe, E-mail to: <[email protected]>
>> ----------------------------------------------------------------
> 
> Best regards,
> 
> Christian Ringele
> Magnolia International Ltd.
> 
> Magnolia®  - Simple Open Source Content Management
> 
> 
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------

Best regards,

Christian Ringele
Magnolia International Ltd.

Magnolia®  - Simple Open Source Content Management



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to