Newslist show different articles, depending on content.
Hello!
I am trying to figure out what would be the best way for making a newslist that show latest articles after date on different pages depending on content. There are going to be three categories, let's call them: Boat - Car - Plane I guess I will have to make some kind of tag-function?
Setup:
Content: - Home (Show five latest articles about Boat, Car and Plane) --Boat (Show five latest articles about Boat) --Car (Show five latest articles about Car) --Plane (Show five latest articles about Plane) --About us --Contact
My solution would be to have the Plane, Boat and Car in different folders. It makes sense to make news for cars under a folder named Cars, and so on…
All newsitems are created based on the same documenttype like newsItem or whatever…
Then it’s easy to show newsitems for the specific folder and to show newsitems on the frontpage where the news are gathered from all newsitems regardless position in the structure.
This will honor you structure and doesn’t require the user to make a selection of Car, Plane or Boat.
On the Home page you can do some xslt like this (from the top of my head):
Have to try both solutions out tonight when I got time. I do like the idea of not having my client to choose each time what category they want it in, even thou that's not work at all.
I'll come back to you guys later, and again thanks for the help!
Newslist show different articles, depending on content.
Hello!
I am trying to figure out what would be the best way for making a newslist that show latest articles after date on different pages depending on content.
There are going to be three categories, let's call them: Boat - Car - Plane
I guess I will have to make some kind of tag-function?
Setup:
Content:
- Home (Show five latest articles about Boat, Car and Plane)
--Boat (Show five latest articles about Boat)
--Car (Show five latest articles about Car)
--Plane (Show five latest articles about Plane)
--About us
--Contact
Any tip would be greatly appreciated!
Regards,
Fredrik
Hi Fredrik,
You should make a document type for the news, lets call it "NewsItem".
Create a datatype in teh developer section, called "Vehicle" and use the render control "Dropdownlist", database datatype "Ntext".
Save it and then you will be able to add your categories: boat/car/plane.
Add this datatype to your news document type and to any other document type you have and make it mandatory, if you need all of them categorized.
After that you can access the categories with XSLT and filter on date and category, date is not done in the example below
<xsl:param name="currentPage"/>
<!-- category fo rhte current page-->
<xsl:variable name="currentPageCat" select="$currentPage/data[@alias = 'Vehicle']"/>
<!-- HomePage : change your doc type -->
<xsl:variable name="source" select="$currentPage/ancestor-or-self::node[@nodeTypeAlias = 'HomePage']/@id"/>
<xsl:template match="/">
<ul>
<xsl:for-each select="umbraco.library:GetXmlNodeById($source)//node[nodeTypeAlias = 'NewsItem'][string(data[@alias = 'Vehicle']) = $currentPageCat]">
<xsl:sort select="substring(@createDate, 1, 4)" order="descending"/>
<xsl:sort select="substring(@createDate, 6, 2)" order="descending"/>
<xsl:sort select="substring(@createDate, 9, 2)" order="descending"/>
<xsl:sort select="substring(@createDate, 12, 2)" order="descending"/>
<xsl:sort select="substring(@createDate, 15, 2)" order="descending"/>
<xsl:sort select="substring(@createDate, 18, 2)" order="descending"/>
<li><value-of select="@nodeName"/></li>
</xsl:for-each>
</ul>
<!-- start writing XSLT -->
</xsl:template>
</xsl:stylesheet>
hope this helps
Len.
Hi Fredrik
My solution would be to have the Plane, Boat and Car in different folders. It makes sense to make news for cars under a folder named Cars, and so on…
All newsitems are created based on the same documenttype like newsItem or whatever…
Then it’s easy to show newsitems for the specific folder and to show newsitems on the frontpage where the news are gathered from all newsitems regardless position in the structure.
This will honor you structure and doesn’t require the user to make a selection of Car, Plane or Boat.
On the Home page you can do some xslt like this (from the top of my head):
And for the subfolders try something like:
Hope it gets you going
/Finn
Thanks alot to both of you!!
Have to try both solutions out tonight when I got time. I do like the idea of not having my client to choose each time what category they want it in, even thou that's not work at all.
I'll come back to you guys later, and again thanks for the help!
Regards,
Fredrik
To bad I can't put solve on both of you, but I went with Finn's way in the end!
Thanks for the help guys!
Regards,
Fredrik
is working on a reply...