Ive tried to split the DateFolder up into years, months and news items in variables, but i still keep getting either repeated news items or issues with the months.
Has anyone used the DateFolders package and could help me wit the XSLT.
Sorry, ive got a sort issue with my DateFolders now.
I have a datepicker field attached to my NewsItem doctype. This date picker called startDate is used to override the createDate and places the news items in a chosen folder.
Im struggling to sort my Datefolders based on the the startDate field.
PS: You should consider creating new threads - it can be hard to find solutions to specific topics, if some of them are "hidden" in the comments of another topic.
DateFolders XSLT Issues
Hi,
Im having issues with my DateFolders XSLT.
Im trying to output code that looks like
2012
> January
>>News Item
>>News Item
> Febuary
>>News Item
>>News Item
Ive tried to split the DateFolder up into years, months and news items in variables, but i still keep getting either repeated news items or issues with the months.
Has anyone used the DateFolders package and could help me wit the XSLT.
Thanks
Martin
My xslt has been stripped back
Hi Martin,
The XPaths you've supplied does in fact select "everything around me", so that's probably why it happens.
Start by creating a siteRoot variable after currentPage - this one should go up to the level of your site's Home node (usually @level=1):
Now, create another variable that selects from the $siteRoot variable, grabbing the "year" nodes, e.g.:
(Remember to tweak the path - here, I'm guessing there's a node called 'News' and that the children of that are the Year folders.)
Now you're ready to start the for-each:
/Chriztian
Thanks Christian,
Im getting the year and month output, but the months are repeating under each of the years.
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
<xsl:variable name="years" select="$siteRoot/*[@nodeName = 'News Archive']/*[@isDoc]" />
<xsl:variable name="months" select="$siteRoot/*[@nodeName = 'News Archive']/DateFolder/*[@isDoc]" />
<xsl:variable name="newsItem" select="$siteRoot/*[@nodeName = 'News Archive']/DateFolder/DateFolder/*[@isDoc]" />
<xsl:template match="/">
<ul>
<xsl:for-each select="$years">
<li class="years">
<xsl:value-of select="@nodeName"/>
<ul>
<xsl:for-each select="$months">
<li class="months">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</li>
</xsl:for-each>
</ul>
</xsl:template>
Hi Martin,
Yes - see, once you've got the years, you automatically have the rest. Just dig in:
/Chriztian
Ah, Thanks Chriztian,
I see it now.
Thanks again.
Hi Chriztian,
The DateFolders package im using automatically names the folders as numbers.
Is there any way to change the node name into a months?
Thanks
Martin
Hi Martin,
You just mean to display the monthname, right? (As opposed to renaming the actual folders in the backoffice).
Do you have multiple languages in the site so you need to supply the names in more than one language?
/Chriztian
Hi,
Im fine with just renaming the months as the appear on the site.
Its only in English.
Hi Martin,
Then I'd just create a lookup variable with the names and pick from that one using the @nodeName index - like this:
/Chriztian
Thanks Chriztian.
There was a typo with the "msxsl" that threw me for a second.
But thanks again.
Sorry, ive got a sort issue with my DateFolders now.
I have a datepicker field attached to my NewsItem doctype. This date picker called startDate is used to override the createDate and places the news items in a chosen folder.
Im struggling to sort my Datefolders based on the the startDate field.
Any help would be grateful.
Martin
Hi Martin,
What do you need to sort? Isn't that what the DateFolder package does for you?
Anyway - you can use this sort instruction inside a for-each to sort on the newsDate property of whichever nodes are being iterated:
/Chriztian
PS: You should consider creating new threads - it can be hard to find solutions to specific topics, if some of them are "hidden" in the comments of another topic.
is working on a reply...