The Quotes and Quote have each a document type "Quotes" and "Quote", where Quote has the properties quoteText and quoteName.
How can I create my xslt so for each Quote node, which use the Quote document type, it writes the quote text and quote name.. and then display a random node, so I can place the macro on eg. frontpage and a subpage?
and added a parameter with alias randomNode to the macro, but it doesn't seem to give a output. I'm using Umbraco 4.7 with the new xml schema .. I have tried with /macro/randomNode/* [@isDoc] too, but doesn't work .
So if you take a look at the temporary url here: http://d22299829.u330.surftown.dk/da/ydelser.aspx , then the quote in the left sidebar on subpages change when you refresh the page or go to another page..
How to display random quote?
Hi
I have the following structure of my content:
- Content
The News and Quotes node are at same level.
Hi, for the random node, it's simple :
For the macro, you name the parameter alias randomNode and choose contentRandom as type.
Hi Bjarne
I haven't tested it, but it should work
I have wrote the following in my XSLT:
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:variable name="randomNode" select="/macro/randomNode/*"/>
<xsl:value-of select="$randomNode/quoteName" disable-output-escaping="yes" />
<p><xsl:value-of select="$randomNode/quote" disable-output-escaping="yes" />
</p>
</xsl:template>
and added a parameter with alias randomNode to the macro, but it doesn't seem to give a output. I'm using Umbraco 4.7 with the new xml schema .. I have tried with /macro/randomNode/* [@isDoc] too, but doesn't work .
Is something missing?
Hi Sebastian
Thank you so much for your input :)
Just what I needed... it now works perfectly as intended.
Your code works, just my Master doc types actually is called MainMaster.
So if you take a look at the temporary url here: http://d22299829.u330.surftown.dk/da/ydelser.aspx , then the quote in the left sidebar on subpages change when you refresh the page or go to another page..
Once again I appreciate your help..
- Bjarne
Hi Sebastian
Would you mind sharing this in the wiki if it does not already exist in there? Nice solution indeed :-)
/Jan
@Jan and @Bjarne
Here you go: http://our.umbraco.org/wiki/how-tos/xslt-useful-tips-and-snippets/xslt-getting-a-random-document-when-the-page-reloads
I've optimized it a bit using root instead of the MainMaster doctype.
is working on a reply...