This all worked well, the menu is dynamic relative to the pages and all, but I want to change each menu items class when the following is true "current page = selected page".. So I tried this out for size:
You don't need to compare the URLs but just the ID of the currentPage vs the page in your loop, try this:
<xsl:choose> <xsl:when test="$currentPage/@id = @id"> <!-- compares the currentPage's ID to the id of the current page in your loop --> <div class="btnLeftSelect"> </div> </xsl:when> <xsl:otherwise> <div class="btnLeftDeSelect"> </div> </xsl:otherwise> </xsl:choose>
Also here's another way to write it, maybe simpler:
In my News("Nyheder" as seen in the link) menu. Here I would like it to keep the News menu highlighted, even though its not actually on that page but on a sub page...
So you click on news(Nyheder), after that you click on a news item in the body, from here you will be redirected to the specific news page. On this page I would like that the News menu icon keeps being highlighted through the before mentioned class.. Would this be possible through the xslt without the need of something big?
<xsl:when test="$currentPage/@id = ./ancestor-or-self::* [@isDoc]/@id"> <!-- compares the currentPage's ID to the ID of the current page in your loop and it's ancestors -->
Instead of flooding the forum with new topics when ever there is a problem, I'll just continue in this thread, even though the topic title doesn't contain it... (If you want me to I can create a seperate thread though)...
This is my xml:
<RMTNews id="1136" lalallalalalalallalalalalalalal isDoc=""> <newstitle>Nyheder</newstitle> <RMTNewsItem id="1137" lalalalalla nodeName="News Item 1" morelalalla isDoc=""> <newsitemtitle>Ringsted Morskabsteater er nu i alpha!</newsitemtitle> <newsitemtext> <p>Vi har den glæde at præsenterer jer for den nye hjemmeside for Ringsted Morskabsteater.</p> </newsitemtext> <newsitemowner>0</newsitemowner> <newsitemdate>2011-11-10T00:00:00</newsitemdate> </RMTNewsItem> </RMTNews>
I can get the nodeName without any problems... But I would also like to get the newsitemdate value and ofcourse format it to something readable... This is what I tried, and failed...(I normally hate XML, not how its written, but the stupidity of the access <- in my mind that is) Though I love the simplicity...
When you use the @ sign you are asking for an attribute of your node, for example id, nodeName, etc. The attributes are typically the built-in properties of Umbraco (sortorder, path, id, createDate, etc)
To get a custom property (which are elements under your node rather than attributes), just omit the @ sign.
<xsl:value-of select="newsitemdate"/>
Next, to format the date you can use an extension method FormatDateTime
Change class on div when url matches $currentPage
Hi, This is my second website that im using umbraco for, and this time I decided that I wanted to try out the dynamic menu using the xslt.
an alpha of the site can be seen at: http://alpha.yilmas.dk
This all worked well, the menu is dynamic relative to the pages and all, but I want to change each menu items class when the following is true "current page = selected page".. So I tried this out for size:
<xsl:choose>
<xsl:when test="$currentPage=umbraco.library:NiceUrl(@id)">
<div class="btnLeftSelect"> </div>
</xsl:when>
<xsl:otherwise>
<div class="btnLeftDeSelect"> </div>
</xsl:otherwise>
</xsl:choose>
Im using the template "List Sub Pages by Level".. So I was guessing that $currentPage would give me what I needed...
Also note that this is the first time that I've touched XSLT, normally I would do this in a usercontrol, but wanted to test the possibiliies in XSLT..
So can anyone help me to achieve what I want ?
Hi,
You don't need to compare the URLs but just the ID of the currentPage vs the page in your loop, try this:
Also here's another way to write it, maybe simpler:
Hope this helps,
Tom
Thank you very much... Works like a charm... I used your first solution, as for me, it seemed easier..
Though I will save both solutions, might need one of them some day...
One more question...
In my News("Nyheder" as seen in the link) menu. Here I would like it to keep the News menu highlighted, even though its not actually on that page but on a sub page...
So you click on news(Nyheder), after that you click on a news item in the body, from here you will be redirected to the specific news page. On this page I would like that the News menu icon keeps being highlighted through the before mentioned class.. Would this be possible through the xslt without the need of something big?
Yep, you can do that, I think this should work:
Thx, works like a charm...
Instead of flooding the forum with new topics when ever there is a problem, I'll just continue in this thread, even though the topic title doesn't contain it... (If you want me to I can create a seperate thread though)...
This is my xml:
<RMTNews id="1136" lalallalalalalallalalalalalalal isDoc="">
<newstitle>Nyheder</newstitle>
<RMTNewsItem id="1137" lalalalalla nodeName="News Item 1" morelalalla isDoc="">
<newsitemtitle>Ringsted Morskabsteater er nu i alpha!</newsitemtitle>
<newsitemtext>
<p>Vi har den glæde at præsenterer jer for den nye hjemmeside for Ringsted Morskabsteater.</p>
</newsitemtext>
<newsitemowner>0</newsitemowner>
<newsitemdate>2011-11-10T00:00:00</newsitemdate>
</RMTNewsItem>
</RMTNews>
I can get the nodeName without any problems... But I would also like to get the newsitemdate value and ofcourse format it to something readable...
This is what I tried, and failed...(I normally hate XML, not how its written, but the stupidity of the access <- in my mind that is) Though I love the simplicity...
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
<xsl:value-of select="@newsitemdate" />
</a>
Hi,
Not a problem :)
When you use the @ sign you are asking for an attribute of your node, for example id, nodeName, etc. The attributes are typically the built-in properties of Umbraco (sortorder, path, id, createDate, etc)
To get a custom property (which are elements under your node rather than attributes), just omit the @ sign.
Next, to format the date you can use an extension method FormatDateTime
Hope this helps,
Tom
Thx m8, again...
Could you tell me what I must write in this forum to generate those code boxes?
Sure :)
Just type out your text, highlight it, then click on the dropdown that says Paragraph and select Preformatted
is working on a reply...