Copied to clipboard

Flag this post as spam?

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


  • Steve 472 posts 1216 karma points
    May 23, 2014 @ 19:55
    Steve
    0

    Select Property from a Multi-Node Picker

    I have a xslt script that I need to first test to see if there is a value in the property newsZones (which is selected by a multi-node content picker), and then select all the NewsArticles that have that property and list them if the value for newsZones is of the $currentPage. I don't know how to pull the value of the property newsZones or test it against the $currentPage. Suggestions?

    <xsl:variable name="sidebarArticles" select="$category/descendant-or-self::NewsArticle[string(umbracoNaviHide) != '1' and string(@id) != string($currentPage/featuredArticle) or newsZones/MultiNodePicker/nodeId = ($currentPage/ancestor-or-self::*/@id) ]" />
    <div class="news-listing" style="height:500px;overflow:auto;">
          <ul>
            <xsl:for-each select="$sidebarArticles">
              <xsl:sort select="publicationDate" order="descending" />
              <xsl:if test="count($featuredArticles[@id=current()/@id])&lt;=0">
                  <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="headline" /></a><xsl:value-of select="newsZones" /></li>
              </xsl:if>
            </xsl:for-each>
          </ul>
        </div>
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 26, 2014 @ 14:32
    Chriztian Steinmeier
    0

    Hi Steve,

    I'd love to help you out but I can't really follow how your exact setup is, so could maybe explain a little more about how your Content tree is built; where the newsZones property is located, and how the featuredArticles property is supposed to work?

    /Chriztian

  • Steve 472 posts 1216 karma points
    May 27, 2014 @ 15:02
    Steve
    0

    Ok Chriztian, as the script is now, the doctype NewsArticle contains the property newsZones which is a multi-node picker. The News articles are displayed in a feed from a newsFeed macro based on what nodes are selected using the multi-node picker in the NewsArticle. The featuredArticles property is a check box within the NewsArticle which also impacts how the article is displayed within the newsFeed. The featuredArticles will display in the newsFeed while any other NewsArticle will display in another section "sidebarArticles" which are determined by the multi-node picker. I would like to pull the articles from any news article folder, not just the children of the NewsCatagory node as well.

    Below is the xslt used for the feed:

    You can see one of the pages with the NewsArticles here:

    http://www.rose-hulman.edu/news/on-campus.aspx

    <xsl:param name="currentPage"/>
        <xsl:variable name="cutoff" select="90" />
    
    <xsl:template match="/">
    
      <xsl:variable name="category" select="$currentPage/ancestor-or-self::NewsCategory" />
      <xsl:variable name="primaryArticle" select="$currentPage/descendant::NewsArticle[@id = $currentPage/featuredArticle]" />
      <xsl:variable name="featuredArticlesCopy">
        <xsl:for-each select="$currentPage/descendant::NewsArticle[string(@id) != string($currentPage/featuredArticle) and string(umbracoNaviHide) != '1' and string(featureThisArticle) = '1' ]">
          <xsl:sort select="publicationDate" order="descending" />
          <xsl:if test="position() &lt; 8">
            <xsl:copy-of select="." />
          </xsl:if>
        </xsl:for-each>
      </xsl:variable>
      <xsl:variable name="featuredArticles" select="msxml:node-set($featuredArticlesCopy)/NewsArticle" />
      <xsl:variable name="sidebarArticles" select="$currentPage/descendant::NewsArticle[string(umbracoNaviHide) != '1' and string(@id) != string($currentPage/featuredArticle) ]" />
    
        <!-- NEWS FEED SCROLLER ON RIGHT OF NEWS CATEGORY PAGE -->
      <div id="recent-news">
        <xsl:choose>
          <xsl:when test="$category">
            <h3>
              <xsl:text>RECENT </xsl:text>
              <xsl:call-template name="node-name">
                <xsl:with-param name="node" select="$category" />
              </xsl:call-template>
              <xsl:text> NEWS:</xsl:text>
            </h3>
          </xsl:when>
          <xsl:otherwise>
            <h3>ALL RECENT NEWS:</h3>
          </xsl:otherwise>
        </xsl:choose>
    
        <div class="news-listing" style="height:500px;overflow:auto;">
          <ul>
            <xsl:for-each select="$sidebarArticles">
              <xsl:sort select="publicationDate" order="descending" />
              <xsl:if test="count($featuredArticles[@id=current()/@id])&lt;=0">
                <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="headline" /></a></li>
              </xsl:if>
            </xsl:for-each>
          </ul>
        </div>
    
        <div class="recent-news-footer"><xsl:text> </xsl:text></div>
      </div>
    
      <div class="featured-articles">
        <xsl:if test="$primaryArticle">
          <p class="tag">
            <xsl:call-template name="node-name">
              <xsl:with-param name="node" select="$primaryArticle/parent::*" />
            </xsl:call-template>
          </p>
    
          <h2><xsl:value-of select="$primaryArticle/headline" /></h2>
    
          <img src="{concat('/ImageGen.ashx?image=', umbraco.library:GetMedia($primaryArticle/featuredImage, false())/umbracoFile, '&amp;width=526')}" />
          <p class="caption"><xsl:value-of select="$primaryArticle/featuredImageCaption" /></p>
    
          <p>
            <xsl:value-of select="$primaryArticle/teaser" /><br />
            <a href="{umbraco.library:NiceUrl($primaryArticle/@id)}">Read More</a>
          </p>
        </xsl:if>
    
        <div class="featured-listings">
          <xsl:for-each select="$featuredArticles">
            <div class="listing">
              <p class="tag">
                <xsl:call-template name="node-name">
                  <!-- can't do ./parent::* because these nodes are copied and don't have parents -->
                  <xsl:with-param name="node" select="$currentPage/ancestor-or-self::NewsHome//NewsArticle[@id=current()/@id]/ancestor-or-self::NewsCategory" />
                </xsl:call-template>
              </p>
    
              <xsl:if test="string(./featuredImage) != ''">
                <img src="{concat('/ImageGen.ashx?image=', umbraco.library:GetMedia(./featuredImage, false())/umbracoFile, '&amp;width=154')}" />
              </xsl:if>
    
              <div class="listing-content">
                <h3><xsl:value-of select="./headline" /></h3>
    
                <p>
                  <xsl:value-of select="./teaser" /><br />
                  <a href="{umbraco.library:NiceUrl(./@id)}">Read More</a>
                </p>
              </div>
            </div>
          </xsl:for-each>
        </div>
      </div>
    
    </xsl:template>
    
    <!-- A template to output the correct name for a given node. Better than copy/pasting this code all over the place -->
    <xsl:template name="node-name">
      <xsl:param name="node" />
    
      <xsl:if test="string($node) != ''">
        <xsl:choose>
          <xsl:when test="$node/pageTitle != ''">
            <xsl:value-of select="$node/pageTitle"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$node/@nodeName"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
    </xsl:template>
Please Sign in or register to post replies

Write your reply to:

Draft