Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello.
I have a syntax issue. I am trying to pass a parameter with my macro to XSLT and it doesn't like it.
I have a series of content panels and the current page looks for a value. At the momemt it works if I hard encode the name of the content panel:
<xsl:variable name="nodeIds" select="umbraco.library:Split($currentPage/contentpanels,',')" />
But I want this name to come from a passed parameter so that I can have multiple panels that are different without having mutiple XSLT scripts.
I have added the parameter value:
<xsl:param name="cPanel" select="/macro/CPID" /> <xsl:template match="/"> <xsl:if test="string-length($currentPage/$cPanel > 0"> <xsl:variable name="nodeIds" select="umbraco.library:Split($currentPage/$cPanel,',')" />
The parameter is passing the value properly but it fails. I could do with a hand with the syntax.
Thank you.
<?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "><xsl:output method="xml" omit-xml-declaration="yes"/><xsl:param name="currentPage"/> <xsl:param name="cPanel" select="/macro/CPID" /> <xsl:template match="/"> <xsl:if test="string-length($currentPage/$cPanel > 0"> <xsl:variable name="nodeIds" select="umbraco.library:Split($currentPage/$cPanel,',')" /> <xsl:if test="count($nodeIds/value) > 0"> <ul> <xsl:for-each select="$nodeIds/value"> <li> <xsl:value-of disable-output-escaping="yes" select="umbraco.library:RenderTemplate(current()/.,umbraco.library:GetXmlNodeById(current()/.)/@template)"/> </li> </xsl:for-each> </ul> </xsl:if> </xsl:if></xsl:template></xsl:stylesheet>
Hi Streety,
You can set the cPanel variable to the node right away:
<xsl:variable name="cPanel" select="$currentPage/*[name() = /macro/CPID]" />
Then you can just ask for its existence:
<xsl:if test="$cPanel"> <xsl:variable name="nodeIds" select="umbraco.library:Split($cPanel, ',')" /> <xsl:if test="$nodeIds/value"> ... etc ...
/Chriztian
Thanks for that.
<xsl:variable name="nodeIds" select="umbraco.library:Split($cPanel, ',')" />
This worksif I setup the variable manually...ie:
<xsl:variable name="cPanel" select="$currentPage/contentPanels" />
but not as you have suggested
it is passing the parameter in the masterpage
<umbraco:Macro CPID="contentPanels" Alias="[XSLT]ContentPanels" runat="server"></umbraco:Macro>
and the macro has a CPID parameter set to show with its type set to Text.
Not sure what else to try.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Passing a Parameter Variable to $currentPage
Hello.
I have a syntax issue. I am trying to pass a parameter with my macro to XSLT and it doesn't like it.
I have a series of content panels and the current page looks for a value. At the momemt it works if I hard encode the name of the content panel:
But I want this name to come from a passed parameter so that I can have multiple panels that are different without having mutiple XSLT scripts.
I have added the parameter value:
The parameter is passing the value properly but it fails. I could do with a hand with the syntax.
Thank you.
Hi Streety,
You can set the cPanel variable to the node right away:
Then you can just ask for its existence:
/Chriztian
Thanks for that.
This worksif I setup the variable manually...ie:
but not as you have suggested
it is passing the parameter in the masterpage
and the macro has a CPID parameter set to show with its type set to Text.
Not sure what else to try.
is working on a reply...