Related media populating on pages - uComponents Multi-Node Tree Picker
I've created a media type "PDF" and I have added a datatype "relatedPages" (uComponents Mutli-Node Tree picker).
I want to be able to link the uploaded PDF to relevant pages through out the website. Then have those PDF's available to download on the relevant pages.
What would be the best method for achieving this? Cheers, JV
<xsl:param name="currentPage"/> <!-- Input the related links property alias here --> <xsl:variable name="propertyAlias" select="string('relatedPages')"/>
<xsl:template match="/">
<!-- uComponents: Multi-node Tree Picker - An XSLT example ===================================== The Multi-node Tree Picker data-type will provide XML data based on the nodes you have selected. In this example, the property alias name for the Multi-node Tree Picker is "treePicker". -->
<!-- First we check that the Multi-node Tree Picker has any nodeId values --> <xsl:if test="$currentPage/relatedPages/MultiNodePicker/nodeId">
<div class="pdf_download_container"> <ul>
<!-- Loop through each of the nodeId values --> <xsl:for-each select="$currentPage/relatedPages/MultiNodePicker/nodeId">
<!--
Since we only have the nodeId value, we need to get the actual content
node using umbraco.library's GetXmlNodeById method --> <!--
If you prefer to use pure XPath, then used this:
"$currentPage/ancestor-or-self::*[@isDoc and @level =
1]/descendant-or-self::*[@isDoc and @id = current()]" --> <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
<li>
<!-- Output the URL using umbraco.library's NiceUrl method --> <p><a href="{umbraco.library:NiceUrl(.)}">
I've got the PDF media type displaying in the list now, but I need the list to only appear if a PDF has been assigned to that page. And only the PDF's assigned to that page should appear.
The media type "PDF" has a datatype "relatedPages" (uComponents Mutli-Node Tree picker). This is used to pick the pages that the PDF should appear on.
Here's my current XSLT:
<?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:msxsl="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:synrg="urn:my-scripts" exclude-result-prefixes="msxml umbraco.library"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage" /> <xsl:param name="mediafolder" select="/macro/mediaFolder/Folder/@id" /> <xsl:template match="/"> <!--<p><b>mediaFolder:</b> <xsl:value-of select="$mediafolder" /></p>--> <xsl:if test="$mediafolder !=''"> <xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" /> <xsl:variable name="propertyAlias" select="string('relatedPages')"/> <!-- Uncomment this for DEBUG and view the HTML source of your page to see the XML snippet --> <!-- <xsl:copy-of select="$files" /> --> <xsl:if test="$files != ''"> <div class="pdf_download_container"> <ul> <!-- For each XML node <node> where the nodeTypeAlias attribute = File --> <xsl:for-each select="$files/PDF[@nodeTypeAlias = 'PDF']"> <li> <!-- On the current XML node <node> find the XML node <data> where the alias atribute = umbracoFile --> <!-- This is where the filepath to the file is stored --> <a href="{./umbracoFile}" class="external"> <xsl:value-of select="@nodeName" /> </a> <xsl:if test="umbracoBytes != ''"> <span><xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'dd MMMM yy')"/><br/>(<xsl:value-of select="synrg:GetFileSize(((umbracoBytes div 1024) div 1024))" />)</span> </xsl:if> <xsl:if test="description != ''"> <p><xsl:value-of select="description"/><xsl:if test="readMoreLink != ''"> <a href="{umbraco.library:NiceUrl(readMoreLink)}" title="{umbraco.library:GetXmlNodeById(readMoreLink)/@nodeName}">Read more</a></xsl:if></p> </xsl:if> </li> </xsl:for-each> </ul> </div> </xsl:if> </xsl:if> </xsl:template>
<xsl:param name="currentPage"/> <!-- Input the related links property alias here --> <xsl:variable name="propertyAlias" select="string('relatedLinks')"/>
<xsl:template match="/">
<!-- uComponents: Multi-node Tree Picker - An XSLT example ===================================== The Multi-node Tree Picker data-type will provide XML data based on the nodes you have selected. In this example, the property alias name for the Multi-node Tree Picker is "treePicker". -->
<!-- First we check that the Multi-node Tree Picker has any nodeId values --> <xsl:if test="$currentPage/relatedLinks/MultiNodePicker/nodeId">
<!-- Loop through each of the nodeId values --> <xsl:for-each select="$currentPage/relatedLinks/MultiNodePicker/nodeId">
<!-- Since we only have the nodeId value, we need to get the actual content node using umbraco.library's GetXmlNodeById method --> <!-- If you prefer to use pure XPath, then used this: "$currentPage/ancestor-or-self::*[@isDoc and @level = 1]/descendant-or-self::*[@isDoc and @id = current()]" --> <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
<li>
<!-- Output the URL using umbraco.library's NiceUrl method --> <p><a href="{umbraco.library:NiceUrl(.)}">
Thanks Jeroen, but I don't think that will work for what I want.
I'm still no closer with this, but I figure it's just a matter of filtering the "relatedPages" into the "files" variable. So that it will only display on the page if a "relatedPages" value is attached it.
Latest XSLT:
<?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:msxsl="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:synrg="urn:my-scripts" exclude-result-prefixes="msxml umbraco.library"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage" /> <xsl:param name="mediafolder" select="/macro/mediaFolder/Folder/@id" /> <xsl:template match="/"> <!--<p><b>mediaFolder:</b> <xsl:value-of select="$mediafolder" /></p>--> <xsl:if test="$mediafolder !=''"> <!--<xsl:variable name="propertyAlias" select="string('relatedPages')"/> <xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())/descendant-or-self::* [@nodeTypeAlias and string(relatedPages) != '1']" />--> <xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" /> <!--<xsl:variable name="possibleNodes" select="umbraco.library:GetMedia(1315, 'true')/descendant-or-self::* [@isDoc]" />--> <!-- Uncomment this for DEBUG and view the HTML source of your page to see the XML snippet --> <!--<xsl:copy-of select="$files" /> --> <xsl:if test="$files != ''"> <div class="pdf_download_container"> <ul> <!-- For each XML node <node> where the nodeTypeAlias attribute = File --> <xsl:for-each select="$files/PDF[@nodeTypeAlias = 'PDF']"> <li> <!-- On the current XML node <node> find the XML node <data> where the alias atribute = umbracoFile --> <!-- This is where the filepath to the file is stored --> <a href="{./umbracoFile}" class="external"> <xsl:value-of select="@nodeName" /> </a> <xsl:if test="umbracoBytes != ''"> <span><xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'dd MMMM yy')"/><br/>(<xsl:value-of select="synrg:GetFileSize(((umbracoBytes div 1024) div 1024))" />)</span> </xsl:if> <xsl:if test="description != ''"> <p><xsl:value-of select="description"/><xsl:if test="readMoreLink != ''"> <a href="{umbraco.library:NiceUrl(readMoreLink)}" title="{umbraco.library:GetXmlNodeById(readMoreLink)/@nodeName}">Read more</a></xsl:if></p> </xsl:if> </li> </xsl:for-each> </ul> </div> </xsl:if> </xsl:if> </xsl:template>
Related media populating on pages - uComponents Multi-Node Tree Picker
I've created a media type "PDF" and I have added a datatype "relatedPages" (uComponents Mutli-Node Tree picker).
I want to be able to link the uploaded PDF to relevant pages through out the website. Then have those PDF's available to download on the relevant pages.
What would be the best method for achieving this?
Cheers, JV
Here's my XSLT:
I've got the PDF media type displaying in the list now, but I need the list to only appear if a PDF has been assigned to that page. And only the PDF's assigned to that page should appear.
The media type "PDF" has a datatype "relatedPages" (uComponents Mutli-Node Tree picker). This is used to pick the pages that the PDF should appear on.
Here's my current XSLT:
Here's the XSLT I use to display Related links "relatedLinks" I'm trying to figure out what elements of this I can use for my PDF XSLT:
Perhaps you can use this for it? http://ucomponents.codeplex.com/wikipage?title=MultiPickerRelations&referringTitle=Documentation
Jeroen
Thanks Jeroen, but I don't think that will work for what I want.
I'm still no closer with this, but I figure it's just a matter of filtering the "relatedPages" into the "files" variable. So that it will only display on the page if a "relatedPages" value is attached it.
Latest XSLT:
SOLVED!
Here's the final code:
is working on a reply...