Copied to clipboard

Flag this post as spam?

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


  • vaibhav 119 posts 139 karma points
    Mar 16, 2011 @ 10:31
    vaibhav
    0

    help in breadcrumb

    Hello,

    I am trying to make breadcrumb like this

    Home >> Solutions >> By Industry

    I am getting breadcrumb some thing like this ....

    Home  Solutions  By Industry

    This is my code

    <?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="minLevel" select="0"/>

      <xsl:template match="/">

        <xsl:if test="$currentPage/@level &gt; $minLevel">
          <ul>
            <xsl:for-each select="$currentPage/ancestor-or-self::* [@level &gt; $minLevel and string(umbracoNaviHide) != '1']">
                <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName"/>
                </a>
            </xsl:for-each>
            <!-- print currentpage -->

          </ul>
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>

    How to get ">>" in between ?


  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 16, 2011 @ 10:56
    Kim Andersen
    0

    Hi vaibhav

    Try changing the for-each to something like this:


    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level &gt; $minLevel and string(umbracoNaviHide) != '1']">
              <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName"/>
              </a><![CDATA[ >> ]]>
    </xsl:for-each>

    /Kim A

  • vaibhav 119 posts 139 karma points
    Mar 16, 2011 @ 11:59
    vaibhav
    0

    Thanx for reply Kim A.

    If i use

    <![CDATA[ >> ]]>

    then i get my breadcrumb as

    Home >> Solutions >> By Industry >>

    but i want breadcrumb as

    Home >> Solutions >> By Industry

  • Rob Watkins 369 posts 701 karma points
    Mar 16, 2011 @ 12:09
    Rob Watkins
    1

     

    <xsl:variable name="nodes" select="$currentPage/ancestor-or-self::* [@level &gt; $minLevel and string(umbracoNaviHide) != '1']"/>
    <xsl:variable name="count" select="count($nodes)"/> <
    xsl:for-each select="$nodes">
              <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName"/>
              </a> <xsl:if test="position() &lt; $count"><![CDATA[ >> ]]></xsl:if>
    </xsl:for-each>

    Try that.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 16, 2011 @ 12:39
    Kim Andersen
    1

    Ahh yeah, of course. Try this instead:

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level &gt; $minLevel and string(umbracoNaviHide) != '1']">
              <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName"/>
              </a>
             
    <xsl:if test="position() != last()">
    <![CDATA[ >> ]]></xsl:if>
    </xsl:for-each>

    /Kim A

  • Rob Watkins 369 posts 701 karma points
    Mar 16, 2011 @ 12:45
    Rob Watkins
    0

    I didn't know about last(), handy!

    Minor bug: you just need brackets on your position, but that's a very short and neat solution.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 16, 2011 @ 12:49
    Kim Andersen
    0

    Ohh yeah you are right Rob! A typo, I fixed it in the above code now.

    And for the las() part, yes it can be very handy in a lot of situations. Always nice when we don't have to count our items, even though I'm sure your solution would work as well :)

    /Kim A

  • Rob Watkins 369 posts 701 karma points
    Mar 16, 2011 @ 12:51
    Rob Watkins
    0

    It certainly cleans up the code, I've got loads of nav stuff that generates a CSS class to flag the last item that could be enshortened with this!

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 17, 2011 @ 14:43
    Kim Andersen
    0

    Hi vaibhav

    Did you solve your problem with one of the small tweaks Rob and I provided?

    /Kim A

  • vaibhav 119 posts 139 karma points
    Mar 18, 2011 @ 08:50
    vaibhav
    0

    yup thanx....

Please Sign in or register to post replies

Write your reply to:

Draft