Copied to clipboard

Flag this post as spam?

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


  • Accusoft 58 posts 109 karma points
    May 10, 2011 @ 15:54
    Accusoft
    0

    Looping through Child Nodes of Specific Content

    I've got a content item called Knowledgebase that contains several articles.  I'm trying to work on an XSLT document rather than a .NET User Control to show these nodes.  I don't want to use currentPage as the default loop over since I ONLY want it to loop over Knowledgebase articles.  I have the following code working:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp " ">
    ]>
    <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:Level2Course.XsltExtensions.SyntaxHighlighter="urn:Level2Course.XsltExtensions.SyntaxHighlighter"
      exclude-result-prefixes="msxml umbraco.library Level2Course.XsltExtensions.SyntaxHighlighter">
     
      <xsl:output method="xml" omit-xml-declaration="yes"/>
     
      <xsl:param name="currentPage"/>
        <xsl:template match="/">
      <ul>
      <xsl:for-each select="$currentPage/child::* [@parentID = 1073]">
        <li>
          <a class="navigation" href="{umbraco.library:NiceUrl(@id)}"><span><xsl:value-of select="@nodeName"/></span></a>
        </li>
      </xsl:for-each>
      </ul>
    </xsl:template>
     
    </xsl:stylesheet>

    The problem is, I don't want the parent ID hardcoded - I want to be able to copy and paste this into other sites.  

    Thanks in advance for any help.

    Also, does Umbraco keep track of the number of "hits" an item receives?  Is it possible to sort the nodes by most popular?  Thanks!

     

  • Sean Holmesby 61 posts 82 karma points
    May 11, 2011 @ 01:38
    Sean Holmesby
    0

    Could you add a content picker to your Home Page Document, and on each of your sites select the Knowledgebase document?

    That way, in your XSLT, you could grab the home node, find the value of that field, and you would have your Knowledgebase document.

Please Sign in or register to post replies

Write your reply to:

Draft