Copied to clipboard

Flag this post as spam?

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


  • Eddie Foreman 215 posts 288 karma points
    Feb 26, 2011 @ 22:11
    Eddie Foreman
    0

    Excluding document type from site map

    Hi All,

    Thought this would be straight forward enough.  For the site map, I would like to exclude the document 'NewsItems'.  Taken the standard sitemap xslt below and updated the for each to:

    <xsl:for-each select="$parent/* [@isDoc and @level &lt;= $maxLevelForSitemap and name() != 'NewsItem'] ">

    Sitemap xslt:

    <?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:PS.XSLTsearch="urn:PS.XSLTsearch"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch ">

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

    <xsl:param name="currentPage"/>

    <!-- update this variable on how deep your site map should be -->
    <xsl:variable name="maxLevelForSitemap" select="4"/>

    <xsl:template match="/">
    <div id="sitemap">
    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>
    </xsl:call-template>
    </div>
    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
    <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
    <ul>
    <xsl:for-each select="$parent/* [@isDoc and @level &lt;= $maxLevelForSitemap and name() != 'NewsItem'] ">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/></a>
    <xsl:if test="count(./* [@isDoc and @level &lt;= $maxLevelForSitemap]) &gt; 0">
    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="."/>
    </xsl:call-template>
    </xsl:if>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

    Although this removes the news items.  All proceeding siblings of the main news page (parent of news items) are nested under the news page.  Producing the following mark-up:

       ...
    <li><a href="/latest-news.aspx">Latest News</a>
    <ul>
    <li><a href="/useful-links.aspx">Useful Links</a></li>
    <li><a href="/terms-and-conditions.aspx">Terms and Conditions</a></li>
    <li><a href="/privacy-policy.aspx">Privacy Policy</a></li>
    </ul>
    </li>
    ...

    Which should be:

        ...
    <li><a href="/latest-news.aspx">Latest News</a></li>
    <li><a href="/useful-links.aspx">Useful Links</a></li>
    <li><a href="/terms-and-conditions.aspx">Terms and Conditions</a></li>
    <li><a href="/privacy-policy.aspx">Privacy Policy</a></li>
    ...

    Have removed the umbracoNaviHide options, as I want to excluded items by datatype.

    Thanks in advance

    Eddie

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 27, 2011 @ 10:10
    Kim Andersen
    0

    Hi Eddie.

    So what you are trying to achieve is actually to show every node in the content tree on the same level? Or just the items that is children of the excluded page?

    Could you maybe show us the structure of your content nodes?

    /Kim A

  • Eddie Foreman 215 posts 288 karma points
    Feb 27, 2011 @ 11:18
    Eddie Foreman
    0

    Hi Kim,

    Sorry, I want to show every node (excluding the news items) for all levels.  Which is why I thought the sitemap xslt would be a good starting point, as it shows all content nodes.

    Stucture is along the lines of :

    home
         about
              subpages
                   team
                        bio
                           ...
                         Team News
                                news items
                                ...
                   ...
              ...
         products
              subpages
              ...
          news
              news items
             ....
          terms
          privacy
          ...

    So in the above stucture the news items for news and team news would not be shown. The news and team news use a different document type an dso will be included in the site map.

    Thanks,

    Eddie

Please Sign in or register to post replies

Write your reply to:

Draft