Hi there... Hope you can help me getting this to work
I have the following setup:
Pages:Product 1 Product 2 Product 3
Theme 1 - related product: Product 1, Product 3 Theme 2 - related product: Product 2, Product 3 Theme 3 - related product: Product 1
I want to list products that are related to a theme, on the theme page itself.
I have set it up so that when you create a new theme, all products a listed under a tab so you can check off witch products are related to the theme. So far so good...
On the theme template I have then set up a macro that list all products, and this works fine... But this list needs to be sorted, so that only products marked as "related product" under the theme content page are listed... but how?
xslt would be something like:
<xsl:for-each themrelatedProductValue = 1 then /> Write productname here </xsl:for-each>
@Rich: I can see where you are going, but i don't get the "nameOfDocType"... What do you mean? is it what i call the document type for themes ("tema")?
I changed the Xslt-file to the following, but it renders nothing:
...and some other values, but nothing that tells me anything about the theme related products...
I'll just describe more exactly what i have done to list the products when i create a theme:
1: Created Xslt/Macro called "TemaRelateretProdukt.xslt" / "Tema Relateret Produkt" (alias "TemaRelateretProdukt") using "list subpages from a changeable source" and added the parameter "Source" (alias "source") with type set to "Content Picker" to the macro.
2: Created a datatype called "TemaRelateretProdukt" with rendercontrol set to "Ultimate Picker" and set the parentnode to my products (id: 1064).
3: I have then created a tab under my theme document type called "Relaterede produkter" and added the property "TemarelateretProdukt" (alias "temarelateretProdukt")
4: Added the macro to my template and set the parentnode (1064).
...this renders a full list of all products using the standard Xslt without any sorting
Hope this helps even more in describing my challenge...
It is an incredibly versatile control, that'll allow you to select all the theme-related products right on the theme page. You can then go full ninja on them with Chriztian's excellent little _MultiPickerHelper.xslt:
If you are a "purist", the Multi-Node Tree Picker (which saves data as XML) and Chriztian's xsl:key-technique will allow you to do the same thing in pure XSLT and save a few extension calls (and guard against deleted nodes), but unless you run into any such issues, your macro should work well. The MNTP will also let you drag-and-drop the order of the products, but that probably isn't necessary for what you're outputting.
Display item if value checked...
Hi there... Hope you can help me getting this to work
I have the following setup:
Pages: Product 1
Product 2
Product 3
Theme 1 - related product: Product 1, Product 3
Theme 2 - related product: Product 2, Product 3
Theme 3 - related product: Product 1
I want to list products that are related to a theme, on the theme page itself.
I have set it up so that when you create a new theme, all products a listed under a tab so you can check off witch products are related to the theme. So far so good...
On the theme template I have then set up a macro that list all products, and this works fine... But this list needs to be sorted, so that only products marked as "related product" under the theme content page are listed... but how?
xslt would be something like:
<xsl:for-each themrelatedProductValue = 1 then />
Write productname here
</xsl:for-each>
Hope you can help out...
Cheers!...
Hey Crawn,
Something like
<xsl:for-each select="$currentPage/* [name() = 'nameOfDocType' and string(themrelatedProductValue ) = '1']">
</xsl:for-each>
Rich
Can you post a dump of the XML for a theme page? E.g. stick this into the template/macro that renders the theme page to get the raw XML:
Hi Rich and Dan... thx for your time...
@Rich: I can see where you are going, but i don't get the "nameOfDocType"... What do you mean? is it what i call the document type for themes ("tema")?
I changed the Xslt-file to the following, but it renders nothing:
<ul>
<xsl:for-each select="$currentPage/* [name() = 'Tema' and string(temarelateretProdukt) = '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
@Dan: I put what you wrote into the Xslt-file and it renders the following:
<Tema id="1173" parentID="1167" level="3" writerID="0" creatorID="0" nodeType="1171" template="1172" sortOrder="1" createDate="2011-10-19T14:49:31" updateDate="2011-11-11T10:04:10" nodeName="Tema1" urlName="Tema1" writerName="admin" creatorName="admin" path="-1,1059,1167,1173" isDoc=""...
...and some other values, but nothing that tells me anything about the theme related products...
I'll just describe more exactly what i have done to list the products when i create a theme:
1: Created Xslt/Macro called "TemaRelateretProdukt.xslt" / "Tema Relateret Produkt" (alias "TemaRelateretProdukt") using "list subpages from a changeable source" and added the parameter "Source" (alias "source") with type set to "Content Picker" to the macro.
2: Created a datatype called "TemaRelateretProdukt" with rendercontrol set to "Ultimate Picker" and set the parentnode to my products (id: 1064).
3: I have then created a tab under my theme document type called "Relaterede produkter" and added the property "TemarelateretProdukt" (alias "temarelateretProdukt")
4: Added the macro to my template and set the parentnode (1064).
...this renders a full list of all products using the standard Xslt without any sorting
Hope this helps even more in describing my challenge...
Cheers...
If you're using the Ultimate Picker, you might get some tips from Lee's blogpost:
http://blog.leekelleher.com/2009/09/08/umbraco-ultimate-picker-xslt-example/
But it sounds like your setup is the perfect match for the venerable uComponents Multi-Node Tree Picker:
http://ucomponents.codeplex.com/wikipage?title=MultiNodeTreePicker
It is an incredibly versatile control, that'll allow you to select all the theme-related products right on the theme page. You can then go full ninja on them with Chriztian's excellent little _MultiPickerHelper.xslt:
http://pimpmyxslt.com/articles/multipicker/
...although less-than-ninja will do it as well ;)
Hi Dan
Looked at Lee's post and got it working...
The DataType i made was ok, but the xslt was off...
Created a new XSLT-file and Macro with the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="preNodes">
<xsl:variable name="relatedContent" select="$currentPage/relateretProdukt" />
<xsl:variable name="nodeIds" select="umbraco.library:Split($relatedContent, ',')" />
<xsl:for-each select="$nodeIds/value">
<xsl:copy-of select="umbraco.library:GetXmlNodeById(.)"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="nodes" select="msxml:node-set($preNodes)/*[@isDoc]" />
<xsl:if test="count($nodes) > 0">
<div class="related-content">
<h3>Related Content</h3>
<ul>
<xsl:for-each select="$nodes">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each></ul>
</div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
All I changed was the variable alias:
<xsl:variable name="relatedContent" select="$currentPage/relateretProdukt" />
Cheers Dan and thx for the guide ;)
Great that it works now!
If you are a "purist", the Multi-Node Tree Picker (which saves data as XML) and Chriztian's xsl:key-technique will allow you to do the same thing in pure XSLT and save a few extension calls (and guard against deleted nodes), but unless you run into any such issues, your macro should work well. The MNTP will also let you drag-and-drop the order of the products, but that probably isn't necessary for what you're outputting.
is working on a reply...