just news list

Topics: Developer Forum
Dec 9, 2007 at 7:21 PM
Hi,

I would like to make a newslist with just the lastest 3 or 4 news items. Also for the events, just show 3 or 4 upcoming events. How or where to start such a control?

tia
Ronald
Mar 10, 2008 at 7:12 PM


elSteenwijker wrote:
Hi,

I would like to make a newslist with just the lastest 3 or 4 news items. Also for the events, just show 3 or 4 upcoming events. How or where to start such a control?

tia
Ronald


Hello yes me too, it would be a great function... and I am also trying to build this function:
1. The titles and the dates for latest news (for example the 7 latest) are shown on the startpage in box/section.

2. The titles are links and when you click them, you are refered to the news item and the full content on the newspage.
Mar 11, 2008 at 12:36 PM
This is done in sidebar.xsl. But this will effect all sidebar items. I only use the sidebar with news.
See comments below.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
exclude-result-prefixes="content">
<xsl:output method="html" omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="/">
<xsl:if test="count(child::*) > 0"><!--See it there's any newsitem in list. Doesn't show "News" if not-->
<div class="rssChannel">
<h3>News</h3>
<xsl:apply-templates select="rss/channel"/>
</div>
</xsl:if>
</xsl:template>

<xsl:template match="rss/channel">
<xsl:variable name="link" select="link"/>
<xsl:variable name="description" select="description"/>
<xsl:variable name="title" select="title" />
<tr>
<td>
<h2>
<xsl:value-of select="title"/>
</h2>
</td>
</tr>
<tr>
<td>
<ul>
<xsl:apply-templates select="item"/>
</ul>
</td>
</tr>
</xsl:template>

<xsl:template match="item">
<xsl:if test="position() < 4 "> <!--Test if position are less then 4 newsitems-->
<li class="item">
<xsl:variable name="item_link" select="link"/>
<div>
<a href="{$item_link}">
<xsl:value-of select="title"/>
</a>
<small>
<xsl:value-of select="pubDate"/>
</small>
<div class="entry">
<xsl:value-of select="content:encoded"/>
</div>
</div>
</li>
<li class="sidebaritemseparator"/>
</xsl:if>
</xsl:template>

</xsl:stylesheet>
Mar 21, 2008 at 2:51 PM


rickardmagnusson wrote:
This is done in sidebar.xsl. But this will effect all sidebar items. I only use the sidebar with news.
See comments below.

Sorry, but I don't understand...
How do I get the Sidebar and the titles of the news list to show up on the page?
Or to be more specific: How do I get the sidebar to show up at all?


Mar 21, 2008 at 4:04 PM
OK, never mind! I got it... I just had missed to click the "Send to Sidebar" button in the newspage section...



Amani wrote:


rickardmagnusson wrote:
This is done in sidebar.xsl. But this will effect all sidebar items. I only use the sidebar with news.
See comments below.

Sorry, but I don't understand...
How do I get the Sidebar and the titles of the news list to show up on the page?
Or to be more specific: How do I get the sidebar to show up at all?