Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Tony Kiernan 278 posts 341 karma points
    Jun 07, 2011 @ 17:05
    Tony Kiernan
    0

    Creating an 'all categories' naviagation list

    I want to build a heirarchical list of all categories to be on all pages of the store? Any opinions on best practise for this?

    I'm still finding my way with uCommerce.  Building a store based on the example store

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 07, 2011 @ 20:02
    Søren Spelling Lund
    0

    Hi Tony,

    Wonderful. I'm glad to hear that you're getting your feet wet with uCommerce :)

    CommerceLibrary:GetRootCategories has an option to include all sub categories in the XML. It might be just what you're looking for.

  • Tony Kiernan 278 posts 341 karma points
    Jun 08, 2011 @ 15:17
    Tony Kiernan
    0

    Yeah, not really the sub categories, more all.  Was hoping it wouldn't anything too convoluted, or that someone had already done this.  Guess I'll just have to get more fiddly with the xslt.

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 08, 2011 @ 15:35
    Søren Spelling Lund
    0

    It actually includes the full category hierarchy. Just pass in true for the second argument.

    CommerceLibrary:GetRootCategories(string catalogName, bool includeFullStructure)

  • Tony Kiernan 278 posts 341 karma points
    Jun 08, 2011 @ 15:46
    Tony Kiernan
    0

    Cool will have a mess about with it

     

  • Tony Kiernan 278 posts 341 karma points
    Jun 08, 2011 @ 16:08
    Tony Kiernan
    0

    So changing the RootCategories xslt to this

      <xsl:variable name="categories" select="CommerceLibrary:GetRootCategories($catalogName, True)"/>

    Should list all categories in the catalog? Doesn't seem to

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 08, 2011 @ 18:26
    Søren Spelling Lund
    0

    XSLT is particular about the way bool values are passed. You need to use true() instead of True. Basically True is interpreted as a string, which is in turn interpreted as a false value because everything other than 1 is considered false. I know it's a little weird, but just change the code to the following and you're good to go:

    <xsl:variable name="categories" select="CommerceLibrary:GetRootCategories($catalogName, true())"/>
  • Tony Kiernan 278 posts 341 karma points
    Jun 09, 2011 @ 11:27
    Tony Kiernan
    0

    Hmmm.  That's not making any difference.

    As an aside: When I use GetAllCatalogs() is there a value that represents the 'number' id for the catalog?  e.g. @catalogid?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 09, 2011 @ 12:53
    Søren Spelling Lund
    0

    There is in 2.0, but not in 1.5 unfortunately.

    You can use the name though. Works just as well.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 09, 2011 @ 12:58
    Søren Spelling Lund
    0

    It's a silly question, but I have to ask: Are you using a catalog name as opposed to a category name in the call to GetRootCategories?

    Are you getting some output or nothing at all?

  • Tony Kiernan 278 posts 341 karma points
    Jun 09, 2011 @ 17:45
    Tony Kiernan
    0

    Yes, I am using a catalog name.  I have three top-level catelogs and want to list these and all categories below them.  Do I need to restructure my products (ie change the catalogs as categories) to be able to list this?

    >>You can use the name though. Works just as well.

    The xslt is taking the number from the url not the category name.  I want to do a comparison. eg. only list subcategories for the selected category

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 09, 2011 @ 22:12
    Søren Spelling Lund
    0

    I just tried out this piece of code, which grabs the category XML for all categories in the uCommerce catalog. Works fine:

    <xsl:variable name="categories" select="CommerceLibrary:GetRootCategories($catalogName, true())"/>

    I modified the uCommerce Store code to test. Maybe you could try it and see how it works out.

    The XSLT supports both names and ids in place of each other. Take a look at the reference for more options.

    Hope this helps.

  • Tony Kiernan 278 posts 341 karma points
    Jun 10, 2011 @ 11:02
    Tony Kiernan
    0
      <xsl:variable name="catalogs" select="CommerceLibrary:GetAllCatalogs()" />
      <xsl:variable name="catalogSelected" select="umbraco.library:RequestQueryString('catalog')" />

      <ul>
        <xsl:for-each select="$catalogs/catalogs/productCatalog">
          <li>
            <a>
              <xsl:attribute name="href">
                <xsl:value-of select="CommerceLibrary:GetNiceUrlForCatalog(@name)"/>
              </xsl:attribute>
              <xsl:value-of select="@name" disable-output-escaping="yes" />
            </a>

            <!--<xsl:if test="$catalogSelected = @catalog">-->
             
              <xsl:variable name="catalogName" select="@name"/>
              <xsl:variable name="categories" select="CommerceLibrary:GetRootCategories($catalogName, true())" />

              <ul>
                <xsl:for-each select="$categories/categories/category[@displayOnSite='True']">
                  <li>
                    <a>
                      <xsl:attribute name="href">
                        <xsl:value-of select="CommerceLibrary:GetNiceUrlForCategory($catalogName, @name)"/>
                      </xsl:attribute>

                      <xsl:value-of select="@displayName" />//
                      <xsl:value-of select="$catalogSelected" />//
                      <xsl:value-of select="@catalog" />
                    </a>
                  </li>
                </xsl:for-each>
              </ul>
          <!--</xsl:if>-->
          </li>
        </xsl:for-each>
      </ul>

    Still only giving me the top level categories

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 10, 2011 @ 14:07
    Søren Spelling Lund
    0

    Ah I think what's tripping you up is the fact the the XML returned is hierarchical. Your foreach loop is only grabbing the root categories but not looking at the childcategories elements.

    Try outputting the XML structure to see what I'm talking about.

    <textarea><xsl:copy-of select="$categories"/></textarea>

     

  • Tony Kiernan 278 posts 341 karma points
    Jun 10, 2011 @ 16:13
    Tony Kiernan
    0

    OK, think we're getting somewhere.

    So how can I identify a parent category? I can show child categories when a parent is selected, but as soon as I click on a child all the siblings disappear

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 14, 2011 @ 12:58
    Søren Spelling Lund
    0

    Once you find the category you want by name or id, you can navigate up the XML structure by using the .. operator.

Please Sign in or register to post replies

Write your reply to:

Draft