So, on the news list, this looks like this as a h1 heading - Exciting news (26 Apr 2010) - this date being made by the above code
...however, when I use the same value-of-select code as above on the individual news page I get this:
Exciting news
Posted by: Sam ()
Where the same date as on the news list page should go in between the brackets on the individual news article page. However, no date shows. Any ideas why this might be? I don't understand how the date is made in the first place, it uses the nodenames on the datefolders, I get that. And looks like the nodenames and found by the level they are on in the tree structure. Actually, quite confused. I'm very new to all this and have been working hard on it evening after evening for weeks now but so much for me to learn having never done any asp or xml before. only css designing.
If anyone can assist, that'd be fantastic, thanks everyone :)
I think you're going to want to use $currentPage instead of a single dot on the individual page. In your for-each loop the single dot means the current node, in you details page it does not unfortunately, that's what the $currentPage variable is for. :-)
Right, that's great. In the overview page you do have a for-each loop though, that's what I was referring to.
Change the date line to this:
<xsl:value-of select="umbraco.library:FormatDateTime(concat($currentPage/../@nodeName,'-',$currentPage/../../@nodeName,'-',$currentPage/../../../@nodeName) , 'd MMM yyyy')" />
The ".." in the xpath means: walk up the tree one node The "." usually means: curent node. However, this is not the case in Umbraco (not sure why not), so that is where the $currentPage variable comes in handy.
<xsl:value-of select="umbraco.library:FormatDateTime(concat(./../../../@nodeName,'-',./../../@nodeName,'-',./../@nodeName) , 'd MMM yyyy')" />
in the overview page, and:
<xsl:value-of select="umbraco.library:FormatDateTime(concat($currentPage/../@nodeName,'-',$currentPage/../../@nodeName,'-',$currentPage/../../../@nodeName) , 'd MMM yyyy')" />
in the individual page displays the same correct date on both formatted from the folder structure :) I don't quite understand how it works but I will look into this next or I'll never learn!
I am redesigning the website where I work. Been doing webdesign as a hobby for about 10 years. Basically have ended up doing every website for each place I've worked along the way lol. Umbraco is certainly making designing that little bit more enjoyable now though. It's a great package which works very well for me.
FormatDateTime
Hi Everyone,
I'm using the following code to generate a date next to a news title using the folder structure rather than a create date:
<xsl:value-of select="umbraco.library:FormatDateTime(concat(./../../../@nodeName,'-',./../../@nodeName,'-',./../@nodeName) , 'd MMM yyyy')" />
The title is clickable and then goes to a newspage.
The structure is as follows:
News
- Year
- Month
- Day
- News Article
Which gives urls as an example like this:
site.com/latest-news.aspx (news list page)
site.com/latest-news/2010/4/26/Exciting-news.aspx (individual news article page)
So, on the news list, this looks like this as a h1 heading - Exciting news (26 Apr 2010) - this date being made by the above code
...however, when I use the same value-of-select code as above on the individual news page I get this:
Exciting news
Posted by: Sam ()
Where the same date as on the news list page should go in between the brackets on the individual news article page. However, no date shows. Any ideas why this might be? I don't understand how the date is made in the first place, it uses the nodenames on the datefolders, I get that. And looks like the nodenames and found by the level they are on in the tree structure. Actually, quite confused. I'm very new to all this and have been working hard on it evening after evening for weeks now but so much for me to learn having never done any asp or xml before. only css designing.
If anyone can assist, that'd be fantastic, thanks everyone :)
I think you're going to want to use $currentPage instead of a single dot on the individual page.
In your for-each loop the single dot means the current node, in you details page it does not unfortunately, that's what the $currentPage variable is for. :-)
Thanks Sebastiaan,
Sadly, I'm still a bit confused, I don't have a for-each loop around this at all. Here is the code from the indivdual page if this helps:
<h1>
<xsl:value-of select="$currentPage/@nodeName"/>
</h1>
<div class="news-data">
<p><span class="news-writer">Posted by:
<xsl:choose>
<xsl:when test="$currentPage/data [@alias = 'Writer'] != ''">
<xsl:value-of select="$currentPage/data [@alias = 'Writer']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentPage/@writerName"/>
</xsl:otherwise>
</xsl:choose>
(<xsl:value-of select="umbraco.library:FormatDateTime(concat(.././@nodeName,'-',../.././@nodeName,'-',../../.././@nodeName) , 'd MMM yyyy')" />)
</span></p>
</div>
Right, that's great. In the overview page you do have a for-each loop though, that's what I was referring to.
Change the date line to this:
The ".." in the xpath means: walk up the tree one node
The "." usually means: curent node. However, this is not the case in Umbraco (not sure why not), so that is where the $currentPage variable comes in handy.
Oh, maybe the "/" after $currentPage is not necessary, I haven't tested this, so try either one. :)
Thank you so much Sebastian.
It worked by doing the following. Using:
<xsl:value-of select="umbraco.library:FormatDateTime(concat(./../../../@nodeName,'-',./../../@nodeName,'-',./../@nodeName) , 'd MMM yyyy')" />
in the overview page, and:
<xsl:value-of select="umbraco.library:FormatDateTime(concat($currentPage/../@nodeName,'-',$currentPage/../../@nodeName,'-',$currentPage/../../../@nodeName) , 'd MMM yyyy')" />
in the individual page displays the same correct date on both formatted from the folder structure :) I don't quite understand how it works but I will look into this next or I'll never learn!
Thanks for your help :)
Glad it works now! :-)
W3Schools has a few nice beginner tutorials on XSLT, give it a look.
Thanks, I'll take a look :)
I am redesigning the website where I work. Been doing webdesign as a hobby for about 10 years. Basically have ended up doing every website for each place I've worked along the way lol. Umbraco is certainly making designing that little bit more enjoyable now though. It's a great package which works very well for me.
is working on a reply...