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
Hi everyone,
I currently have a macro showing news items on the home page. This works fine when placed on the home page as the path is correctly pointing towards my articles:
<xsl:for-each select="$currentPage/*/umbNewsArticle [@isDoc]">
<xsl:value-of select="introduction" disable-output-escaping="yes"/>
<p><a href="{umbraco.library:NiceUrl(@id)}">Read More</a></p>
</xsl:for-each>
However, as soon as I go to a different page, the information disappears - as the $currentPage/*/umbNewsArrticle is now pointing to the wrong place.
How can I adjust my code so that the select statement will always point to the same place. My site structure is as follows:
Home
- News Landing Page
- News Item 1
- News Item 2
- News Item 3
Any help would be brilliant, cheers.Garry.
Hi Garry,
Try this one: http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid
Bas
Hi Gary you could change your XSLT code to something like
<xsl:variable name="source" select="1200"/> <xsl:template match="/"> <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:value-of select="introduction"disable-output-escaping="yes"/> <p><a href="{umbraco.library:NiceUrl(@id)}">Read Morea>p> </xsl:template>
Hope this helps
//fuji
Or use,
<xsl:value-ofselect="introduction"disable-output-escaping="yes"/><xsl:for-eachselect="$currentPage/ancestor-or-self::* [@level = 1]//* [name() = 'umbNewsArticle']"><p><ahref="{umbraco.library:NiceUrl(@id)}">Read Morea>p>xsl:for-each>
which will travel up your tree until it finds a node at level 1 (=Home) and find all descendants (regardless of level) of type umbNewsArticle.
Cheers,
/Dirk
Thank you both very much.
Fixed it with Fuji's code - thanks!
personally I more like Dirk's code because it is more generic (you don't need to hard code the id).
greetings,
Anthony
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Simple XSLT problem with xsl:for-each select="$currentPage"
Hi everyone,
I currently have a macro showing news items on the home page. This works fine when placed on the home page as the path is correctly pointing towards my articles:
However, as soon as I go to a different page, the information disappears - as the $currentPage/*/umbNewsArrticle is now pointing to the wrong place.
How can I adjust my code so that the select statement will always point to the same place. My site structure is as follows:
Home
- News Landing Page
- News Item 1
- News Item 2
- News Item 3
Any help would be brilliant, cheers.
Garry.
Hi Garry,
Try this one: http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid
Bas
Hi Gary you could change your XSLT code to something like
Hope this helps
//fuji
Or use,
<xsl:value-ofselect="introduction"disable-output-escaping="yes"/>
<xsl:for-eachselect="$currentPage/ancestor-or-self::* [@level = 1]//* [name() = 'umbNewsArticle']">
<p><ahref="{umbraco.library:NiceUrl(@id)}">Read Morea>p>
xsl:for-each>
which will travel up your tree until it finds a node at level 1 (=Home) and find all descendants (regardless of level) of type umbNewsArticle.
Cheers,
/Dirk
Thank you both very much.
Fixed it with Fuji's code - thanks!
personally I more like Dirk's code because it is more generic (you don't need to hard code the id).
greetings,
Anthony
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.