Reputation: 308
I have a site built with Umbraco that has a sidebar with several widgets setup. I need to set it so that one of the widgets (done as XSLT) will only display on a certain page. I've looked at using xsl:if test and matches and can't figure it out.
Upvotes: 0
Views: 144
Reputation: 6304
You're on the right track, but get into the habit of including what you have tried already in your question (code etc).
The Quick + Dirty Method
Find out the ID of you page (found on the properties tab of your node in the Content section) and use the following code:
<xsl:if test="$currentPage/@id = 1234">
<!-- your widget here -->
</xsl:if>
The Cleaner Method
Always try to build your code to be scalable, for instance you may find that you want to include the widget on another page in the future, or deploying your content from staging to production might involve the node IDs changing without you realizing (not often, but can happen).
Add a property to the page in question (let's call it showMyFancyWidget
) as true/false data type, flick it on in the Content section then use the following code:
<xsl:if test="$currentPage/showMyFancyWidget = 1">
<!-- your widget here -->
</xsl:if>
This code will work for Umbraco v4.5.1 onwards. Not too sure about v5, but that's being discontinued in favor of v4.7 anyway
Upvotes: 1