News List Control

May 13, 2008 at 8:55 PM
Hello,

Just wondering if there is a way to show the "news" expanded right from the beginning so you never have to click on it?

Thanks!
May 18, 2008 at 6:10 PM
This has to be configured in sidebar.xsl and Rss.
Notice, this is not an easy change.

My sidbar.xsl displays as follow
title [linebreak]
date  - Description (Excerpt about 80 characters) + ...



The newslist has to be changed(The date is also missing in MWPSK! (It's now added)):

 private void insertRssKeyValue(string RssKey, DataRow row, string PageId, ref Dictionary<string, string> elements)
        {
            string key = string.Empty;
            string value = string.Empty;
            string url = "default.aspx";

            switch (RssKey)
            {
                case "title":
                    value = (string)row["Headline"] ;
                    break;
                case "pubDate":
                    value = (string)((DateTime)row["NewsDate"]).ToShortDateString();
                    break;
                case "link":
                   //************You have to only return the original link below************
                     if (((string)row["RewriteUrl"] != "") || (row["RewriteUrl"] != null))
                    {
                        url = "news/" + (string)row["RewriteUrl"];
                        value = string.Format("~/{0}",url);
                    }
                    else
                    {
                        value = string.Format("~/default.aspx?pg={0}&detail={1}#{2}", PageId, row["Guid"], SectionId);
                    }
                    break;
                case "description":
                    if (HttpContext.Current.Request.RawUrl.Contains("news/"))
                    {
                        //Hack to get the page to sidebar.xsl to display different content depending what page we are viewing.
                        value = "#news# " + HttpContext.Current.Server.HtmlDecode((string)row["Newstext"]);
                    }
                    else
                    {
                        value = HttpContext.Current.Server.HtmlDecode((string)row["Newstext"]);
                    }
                    break;
            }

            if (value != string.Empty)
            {
                elements.Add(RssKey, value);
            }
        }





The sidebar.xsl, inc. removal of htmlcode 


<?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="xml" omit-xml-declaration="yes" indent="yes"/>
       
    <xsl:template match="/">
     
    <xsl:if test="count(child::*) >0 "><!--Test if there's any newsitems-->
      <div class="sidebarbox">
        <h1 class="sidebarheader">Aktuellt</h1>
        <div class="news">
          <xsl:apply-templates select="rss/channel"/>
        </div>
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template match="rss/channel">
    <xsl:variable name="link" select="link"/>
    <xsl:variable name="title" select="title" />
    <xsl:variable name="pubDate" select="Comment" />
   
    <xsl:apply-templates select="item"/> 

  </xsl:template>

  <xsl:template match="item">

    <!--Strips all html tags-->
    <xsl:variable name="desc">
      <xsl:call-template name="strip_HTML">
        <xsl:with-param name="description" select="description"  />
      </xsl:call-template>
    </xsl:variable>
    <!--Strips all html tags-->

    <xsl:variable name="item_date" select="pubDate" />
    <xsl:variable name="item_link" select="link" />
    <xsl:variable name="surl" select="description" />

    <xsl:choose>
      <xsl:when test="contains($surl,'#news#')">

        <xsl:if test="position() &lt; 3">
          <strong>
            <a href="{$item_link}" class="itemlink">
              <xsl:value-of select="title"/>
            </a>
          </strong>
          <br/>
          <xsl:value-of select="$item_date" /> - <xsl:value-of select="substring($desc,8,80)" />...
          <br/>
          <br/>
        </xsl:if>
        <xsl:if test="position() = 3">
          <xsl:if test="count(child::*) >2 ">
           
              <b>&#197;ldre nyheter</b><br />
         
          </xsl:if>
        </xsl:if>
        <xsl:if test="position() &gt; 2">
        
            <a href="{$item_link}" class="itemlink">
              <xsl:value-of select="$item_date" /> - <xsl:value-of select="title"/>
            </a>
   
          <br/>
        </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="position() &lt; 3">
       
            <a href="{$item_link}" class="itemlink">
              <xsl:value-of select="title"/>
            </a>
      
          <br/>
          <xsl:value-of select="$item_date" /> - <xsl:value-of select="substring($desc,8,80)" />...
          <br/>
          <br/>
        </xsl:if>
    </xsl:otherwise>
    </xsl:choose>

  </xsl:template>

  <!--Strips all html tags-->
  <xsl:template name="strip_HTML">
    <xsl:param name="description"/>
    <xsl:choose>
      <xsl:when test="contains($description,'&lt;')">
        <xsl:value-of select="substring-before($description,'&lt;')" disable-output-escaping="yes"/>
        <xsl:choose>
          <xsl:when test="contains(substring-after($description,'&lt;'),'&gt;')">
            <xsl:call-template name="strip_HTML">
              <xsl:with-param name="description">
                <xsl:value-of select="substring-after($description,'&gt;')"/>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$description" disable-output-escaping="yes"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!--Strips all html tags-->

 

  <!--Select all tags that match the phrase  not used-->
  <!--<phrase id="medio">medio</phrase>-->
  <xsl:template match="*" mode="markup">
    <xsl:param name="word" />
    <a href="      <xsl:value-of select="$word" />
    </a>
  </xsl:template>

</xsl:stylesheet>