Rank: Devotee
Joined: 12/11/2006 Posts: 47
|
Hi
I am currently working on a site, where it should be possible to select some banners, which are going to be visible in the right part of the site, throughout the entire site.
On every node it is possible to select some three different banners. To make it easy for my client I would like to inherit the selected banners from a parent-node if none are selected for the current node.
For instance, say that I have only selected three banners on my "frontpage" node and want those three banners to be inherited to the rest of the nodes, if none are selected, how am I going to make this happen?
At the moment I am thinking that I should make some sort of recursive function to make it happen.
My pages have a tab named "Banners", where it is possible to select three banners through the content picker.
In my nodetree I have a node called "Banners" as well, and the structure is the following
Banners - Banner 1 - Banner 2 - Banner 3 - Etc.
I am having some trouble figuring it out - any help, would be very much appreciated.
Let me know if something is unclear :)
/Jan
|
Rank: Devotee
Joined: 12/11/2006 Posts: 47
|
Hmm, after reading my post again it occurs to me that it was not very clear.
The functionality should be something like this.
1: If a banner has been selected for the current node, show it 2: If no banner has been selected move up to the next node and see if there is a banner and if there is select that banner. If not, then take a further step up in the tree and look for a banner.
I think what I am looking for is a reversed recursive function? :)
But I am not quite sure how to write it.
/Jan
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,689 Location: KY, USA
|
Hi, Jan, When you insert a field in a template you can use the recursive= property. It recurses UP the tree until it finds a match. An example would be... Code:<head> <title><?UMBRACO_GETITEM field="title" recursive="true"/></title> </head>
Or, if you're doing this via xslt, check out this thread, in which Casey explains how to do it (be sure to read to the bottom as he also corrects a typo in his original posting)... http://forum.umbraco.org/yaf_postsm27704_XSLT-Tip--Display-a-field-recursively.aspx. cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
Rank: Devotee
Joined: 12/11/2006 Posts: 47
|
Hi Doug,
Thank you for pointing me in the right direction - works like a charm now :)
/Jan
|