Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Djan Blom 99 posts 161 karma points
    Sep 08, 2011 @ 09:01
    Djan Blom
    0

    News-box issue

    Hello,

    Im working on an Umbraco 4.7 solution and have installed the Business site Starterkit.

    http://master8.v5.baseshop.dk/

    On the frontpage I have the News-box next to the BannerImage. But when I go to other pages, such as Virksomheden, the 'umbBusinessFrontpageNews its empty..

    If I then replace that macro with 'umbNewsListItems', it returns the subpages for the current page - instead of the news. Can some one please help me out here.?

     

    /Djan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 09:07
    Dirk De Grave
    0

    Djan,

    Sure we can help, can you post your xslt, so we can chime in on that?

     

    Cheers,

    /Dirk

  • Djan Blom 99 posts 161 karma points
    Sep 08, 2011 @ 09:15
    Djan Blom
    0

    This is my umbNewsListItems

     

    xsl:stylesheet [ ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour tagsLib BlogLibrary ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">



    <div class="newsList">
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
      <xsl:sort select="@updateDate" order="ascending" />
       <h3 class="headline"> <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        a>
      h3>
      <small class="meta">Posted: <xsl:value-of select="umbraco.library:LongDate(@updateDate, true(), ' - ')"/>small><br/>
      <p class="introduction">
        <xsl:value-of select="umbraco.library:ReplaceLineBreaks(introduction)" disable-output-escaping="yes"/>
      p>
      
    xsl:for-each>
      div>

    xsl:template>

    xsl:stylesheet>


  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 07:25
    Dirk De Grave
    0

    Ok, so problem lies in the for-each which will always display the child nodes of the current node being requested on the frontend... you'll have to change that

    <xsl:for-eachselect="$currentPage/ancestor-or-self::* [@level = 1]//* [name() != 'propertyAliasOfNewsItem']">
      <xsl:sortselect="@updateDate"order="ascending"/>
       <h3class="headline"><ahref="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-ofselect="@nodeName"/>
        </a>
      </h3>
      <smallclass="meta">Posted: <xsl:value-ofselect="umbraco.library:LongDate(@updateDate, true(), ' - ')"/></small><br/>
      <pclass="introduction">
        <xsl:value-ofselect="umbraco.library:ReplaceLineBreaks(introduction)"disable-output-escaping="yes"/>
      </p>
     
    </xsl:for-each>

    So, basically two changes: always traverse up your tree to find a node at level = 1 (which will be your home page) and from there, find any news item nodes (regardless of their level - hence the //)

    -> Have to replace 'propertyAliasOfNewsItem' with the alias of your news item document type

     

    Hope this helps.

    Regards,

    /Dirk

     

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 07:28
    Dirk De Grave
    0

    Holy, my post didn't get posted... Damn!

    <xsl:for-eachselect="$currentPage/ancestor-or-self::* [@level = 1]//* [name() = 'aliasOfNewsItem']">

    First traverse up the tree to find a node at level = 1 (probably your home page) and get all child nodes (regardless of level - hence the //) of type aliasOfNewsItem -> Have to replace 'aliasOfNewsItem' with the alias of the document type for your news item.

     

    Hope this helps.

    Cheers,

    /Dirk

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 07:31
    Dirk De Grave
    0

    Huh, pretty weird behaviour, my posts are listed before you've posted your xslt... which was my starting point for an answer.... will report that.

     

    /Dirk

  • Djan Blom 99 posts 161 karma points
    Sep 08, 2011 @ 07:48
    Djan Blom
    0

    And my umbBusinessFrontNews:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">


      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>

      <xsl:variable name="numberOfItems">
        <xsl:choose>
          <xsl:when test="/macro/numberOfItems != ''">
            <xsl:value-of select="/macro/numberOfItems"/>
          </xsl:when>
          <xsl:otherwise>5</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:variable name="excerptLength">
        <xsl:choose>
          <xsl:when test="string(/macro/excerptLength) != ''">
            <xsl:value-of select="/macro/excerptLength"/>
          </xsl:when>
          <xsl:otherwise>100</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:template match="/">

        <h3>Latest blog posts</h3>
        <ul class="summaryList" id="blogSummary">
          <xsl:for-each select="$currentPage/umbBlog/umbBlogPost [@isDoc and string(umbracoNaviHide) != '1']">
            <xsl:if test="position() &lt;= $numberOfItems">
              <li>
                <h4>
                  <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="@nodeName"/>
                  </a>
                </h4>
                <p>
                  <xsl:choose>
                    <xsl:when test="string($excerptLength) != '0'">
                      <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(bodyText), number($excerptLength), '...')" disable-output-escaping="yes"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="bodyText" disable-output-escaping="yes"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </p>
                <small>
                  <xsl:value-of select="umbraco.library:ShortDate(PostDate)"/>
                </small>
              </li>
            </xsl:if>
          </xsl:for-each>
        </ul>

      </xsl:template>

    </xsl:stylesheet>
  • Djan Blom 99 posts 161 karma points
    Sep 08, 2011 @ 12:05
    Djan Blom
    0

    Really wierd behavior yes.

    I posted this instead of the XSLT For-each :

    <xsl:for-eachselect="$currentPage/ancestor-or-self::* [@level = 1]//* [name() = 'umbNewsArea']">

    But now I just dont see any posts on my News-page?

     

    http://master8.v5.baseshop.dk/nyheder.aspx

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 12:10
    Dirk De Grave
    0

    Ok, weird behaviour was due to server time zone settings change, so that's solved :p

    you don't see any news items on your news page.. i guess you're using the wrong document type alias, shouldn't it be the alias of the news item instead of the news area, as that's the only item being outputted?

     

    Cheers,

    /Dirk

  • Djan Blom 99 posts 161 karma points
    Sep 08, 2011 @ 18:44
    Djan Blom
    0

    Aha okay :)

    Yes ofcourse, I switched it to umbNewsArticle and it posts like a charm! :) Thanks so much!

    Another question - how do I make it only put out like 256 char's?

Please Sign in or register to post replies

Write your reply to:

Draft