This time I am using a uComponents "Multi Node Tree Picker" (mntp)
The basic idea is that the document type inherits from a "public" type. So the document type inheritance looks like:
+ Public [property:logo-picker] + - Section + - Article
And so all section and article document types inherit a "logo-picker" document property from the public property. The logo picker is a data type base on the mntp and allows you to select logos from a specific "folder/node/mediaType" in the media library. Then my site is organised into sections and articles, and sections can contain articles, or deeper sections, and articles can contain sub sections too.
EG: + Section : Social Media Products - + Article : Twitter Facebook - + Section : Integration - - + Article: Open ID - - + Article: API and over sharing + Section: CMS - +Article: Umbraco - - + Article: Team Lotus - - + Article: Lexus Marketing Hub - - + Article: Rolls Royce - - + Article: RichardBridgland.com - +Article: Ektron - - + Article: TalkToFrank - - + Article: City-Index
Every document type has the logo picker property containing either none or some logos picked. If none are picked then the setting of the parent or it's parent. So if the logo-picker has no picks set for a document node it inherits the setting of it's parent's node.
a simplified copy of the xml document config for that page is here
showing a couple of articles inside a section and the articles have no logos selected in the picker and the containing parent has the sections but in this case it doesn't work correctly
<Section id="1060" parentID="1054" level="2" nodeName="Open Source Software" isDoc=""> <Article id="1261" parentID="1060" level="3" nodeName="Search Solutions" isDoc=""> <contentHeading>Search Solutions</contentHeading> <contentFirstPara><![CDATA[<p>Our open source search solutions use the Lucene... etc ]]></contentFirstPara> <contentBody><![CDATA[<p>We offer our search solution under a comprehensive web based interface to allow control of the following.</p>ETC ]]></contentBody> <umbraco301MovedPermanently /> <logoPicker><![CDATA[]]></logoPicker> <logoHide>0</logoHide> </Article> <Article id="1146" parentID="1060" level="3" nodeName="Content Management Systems" isDoc=""> <contentHeading>Content Management Systems</contentHeading> <contentFirstPara><![CDATA[<p>We know we have the open source products ETC.</p>]]></contentFirstPara> <contentBody><![CDATA[<p>We have delivered dozens of CMS-driven ETC</p>]]></contentBody> <umbraco301MovedPermanently /> <logoPicker><![CDATA[]]></logoPicker> <logoHide>0</logoHide> </Article> <sectionImage /> <sectionIcon>1118</sectionIcon> <contentHeading>Open Source Software</contentHeading> <contentFirstPara><![CDATA[<p>Much has been reported about Open Source technologies and now, with such a focus on ETC.</p>]]></contentFirstPara> <contentBody><![CDATA[<p>These are the questions we are most frequently ETC</p>]]></contentBody> <metaHideNav><![CDATA[]]></metaHideNav> <logoLabel>Open Source customers include</logoLabel> <umbraco301MovedPermanently /> <logoPicker> <MultiNodePicker type="media"> <nodeId>1119</nodeId> <nodeId>1255</nodeId> <nodeId>1259</nodeId> </MultiNodePicker> </logoPicker> <logoHide>0</logoHide> </Section>
First of all - The recursive lookup you're doing is technically OK - I can't see why it would fail at times, but it shouldn't be necessary to do a recursive template here - if you create a match template for logoPicker you should be able to use apply-templates like this:
<xsl:template match="/">
<xsl:if test="$currentPage[logoHide = 1]">
<!-- Find the nearest ancestor (or myself) that has any logos picked -->
<xsl:variable name="recursiveLogoNode" select="$currentPage/ancestor-or-self::*[normalize-space(logoPicker//nodeId)][1]" />
<h4><xsl:value-of select="$recursiveLogoNode/logoLabel"/></h4>
<!-- Process the logos picked on this -->
<xsl:apply-templates select="$recursiveLogoNode/logoPicker" />
<!-- more stuff -->
</xsl:template>
<!-- Template for the logoPicker property -->
<xsl:template match="logoPicker">
<xsl:for-each select="MultiPicker/nodeId">
<!-- Do the usual GetImage() stuff -->
</xsl:for-each>
</xsl:template>
Note: Be careful with the logoHide property check - you should always check for the expected value - the way you're checking will probably always return true because you're actually just checking if the logoHide property is there. Maybe this is part of the reason you're getting weird results?
- it just goes to show that such a clown move *does* happen from time to time, and it's good to be reminded about it so you're aware of at least one extra point of failure to examine :-)
recursively finding multi node tree picker parent property if none selected on current page
I'm reprising an idea I did previously with an embedded content control.
http://our.umbraco.org/projects/backoffice-extensions/embedded-content/general/26558-recursive-embedded-content
This time I am using a uComponents "Multi Node Tree Picker" (mntp)
The basic idea is that the document type inherits from a "public" type. So the document type inheritance looks like:
And so all section and article document types inherit a "logo-picker" document property from the public property. The logo picker is a data type base on the mntp and allows you to select logos from a specific "folder/node/mediaType" in the media library. Then my site is organised into sections and articles, and sections can contain articles, or deeper sections, and articles can contain sub sections too.
Every document type has the logo picker property containing either none or some logos picked. If none are picked then the setting of the parent or it's parent. So if the logo-picker has no picks set for a document node it inherits the setting of it's parent's node.
I've approached this by using a call-template:
<xsl:otherwise> <xsl:call-template name="IterateLogo"> <xsl:with-param name="node" select="$node/parent::*" /> </xsl:call-template> </xsl:otherwise>
so this then recursively calls itself until finds a node which has a count of at least one nodeId in the logo-picker
and then processes this node
and so follows the starting match="/" template
however this doesn't work all the time
i have one specific example that isn't working
a simplified copy of the xml document config for that page is here
showing a couple of articles inside a section and the articles have no logos selected in the picker and the containing parent has the sections but in this case it doesn't work correctly
Hi John,
First of all - The recursive lookup you're doing is technically OK - I can't see why it would fail at times, but it shouldn't be necessary to do a recursive template here - if you create a match template for logoPicker you should be able to use apply-templates like this:
Note: Be careful with the logoHide property check - you should always check for the expected value - the way you're checking will probably always return true because you're actually just checking if the logoHide property is there. Maybe this is part of the reason you're getting weird results?
/Chriztian
OOH thanks Chriztian amazing :) i'll try that
I like your solution much more and I've changed it to this.
But I can't believe what an idiotic mistake I just made, that's had me foxed for over a month.
An old classic chestnut. It did not appear some of the time because one template did not have the macro call on it.
Shoot me now :-$
Ha :)
- it just goes to show that such a clown move *does* happen from time to time, and it's good to be reminded about it so you're aware of at least one extra point of failure to examine :-)
Have a merry Christmas John,
/Chriztian
aaah the tears of a clown :)
merry christmas to you too
is working on a reply...