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.

  • Dan Sunesen 45 posts 145 karma points
    Feb 04, 2013 @ 15:18
    Dan Sunesen
    0

    Get products under each category

    Hey folks,

    I'm kinda new to uCommerce, and i'm trying to figure out how all it works.

    I have managed to list all categories in my navigation, but I cannot seem to get the actual products showing.

    The way my navigation works is by hovering over a menu item called Product, which expands and shows all categories in uCommerce. 

    What I need is a way of showing products under each category, when I hover over each category item.

     

     

    The code I've got working so far is:

     

       <xsl:template match="ProductOverviewPage">
            <xsl:variable name="catalogName" select="umb:RequestQueryString('catalog')"/>
            <xsl:variable name="categoryName" select="umb:RequestQueryString('category')"/>
            <xsl:variable name="categories" select="CommerceLibrary:GetRootCategories($catalogName, false)"/>
    
    
    
            <li>
                <xsl:if test="descendant-or-self::*[@id = $currentPage/@id]">
                    <xsl:attribute name="class">selected</xsl:attribute>
                </xsl:if>
                <a href="{&NiceUrl;(@id)}">
                    <xsl:value-of select="@nodeName" />
                </a>
    
                    <div class="sub-menu">
                        <ul>
                        <xsl:for-each select="$categories/categories/category[@displayOnSite='True']">
                          <li>
                            <a>
                              <xsl:attribute name="href">
                                            <xsl:value-of select="CommerceLibrary:GetNiceUrlForCategory($catalogName, @id)"/>
                              </xsl:attribute>
                              <xsl:value-of select="@displayName"/>
                            </a>
                                    <div class="sub1 cf">
                                        <xsl:if test="position() = '1'">
                                            <xsl:attribute name="class">sub1 cf begin</xsl:attribute>
                                        </xsl:if>
                                        <div class="box1">                                        
                                        <h2><xsl:value-of select="@displayName" /></h2>
                                    <p><xsl:value-of select="@description"/></p>
                                        <a href="{CommerceLibrary:GetNiceUrlForCategory($catalogName, @id)}" class="more">link</a>
                                    </div>
    
    
                                            <div class="flexslider-mini flexmini">
                                            <ul class="items slides">
                                                    <!-- THIS IS WHERE THE PRODUCTS SHOULD BE LISTED -->
                                                </ul>
                                            </div>
                                    </div>
                          </li>
                        </xsl:for-each>
                      </ul>
                    </div>    
            </li>
        </xsl:template>

     

    This template renders each category, now I need to show childProducts.

     

    Br
    Dan

  • Dan Sunesen 45 posts 145 karma points
    Feb 04, 2013 @ 15:28
    Dan Sunesen
    0

    Sry for the bad formatting - Tried to make it look better... :/

  • Dan Sunesen 45 posts 145 karma points
    Feb 04, 2013 @ 21:16
    Dan Sunesen
    0
  • Dan Sunesen 45 posts 145 karma points
    Feb 06, 2013 @ 15:17
    Dan Sunesen
    100

    I managed to get it working. 

    Here's the result:

     

    <xsl:template match="ProductOverviewPage">

    <xsl:variable name="catalogName" select="umb:RequestQueryString('catalog')"/>

    <xsl:variable name="categoryName" select="umb:RequestQueryString('category')"/>

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

     

    <li>

    <xsl:if test="descendant-or-self::*[@id = $currentPage/@id]">

    <xsl:attribute name="class">selected</xsl:attribute>

    </xsl:if>

    <a href="{&NiceUrl;(@id)}">

    <xsl:value-of select="@nodeName" />

    </a>

     

    <div class="sub-menu">

    <ul>

       <xsl:for-each select="$categories/categories/category[@displayOnSite='True']">

         <li>

           <a>

             <xsl:attribute name="href">

    <xsl:value-of select="CommerceLibrary:GetNiceUrlForCategory($catalogName, @id)"/>

             </xsl:attribute>

    <img width="33" height="24">

    <xsl:attribute name="src">/pimmedia/image/<xsl:value-of select="properties/CategoryImageName" /></xsl:attribute>

    </img>

             <xsl:value-of select="@displayName"/>

           </a>

    <div class="sub1 cf">

    <xsl:if test="position() = '1'">

    <xsl:attribute name="class">sub1 cf begin</xsl:attribute>

    </xsl:if>

    <div class="box1">

       <h2><xsl:value-of select="@displayName" /></h2>

         <xsl:value-of select="@description" disable-output-escaping="yes"/>

       <a href="{CommerceLibrary:GetNiceUrlForCategory($catalogName, @id)}" class="more">link</a>

     </div>

     

    <div class="flexslider-mini flexmini">

     <ul class="items slides">

    <xsl:variable name="thisName" select="@name"/>

    <xsl:variable name="category" select="CommerceLibrary:GetCategory($catalogName, $thisName)"></xsl:variable>

    <xsl:for-each select="$category/category/childProducts/product">

    <li>

    <a href="{CommerceLibrary:GetNiceUrlForProduct($catalogName, $thisName, @id)}/?sku={@sku}">

    <xsl:choose>

    <xsl:when test="@thumbnailImage[normalize-space()]">

    <img src="{@thumbnailImage}" alt="{@shortDescription}" />

    </xsl:when>

    <xsl:otherwise>

    <img src="/images/item1.jpg" alt="Product" />

    </xsl:otherwise>

    </xsl:choose>

    <span>

    <xsl:value-of select="@displayName" />

    </span>

    </a>         

    </li>

    </xsl:for-each>

    <textarea rows="8" cols="40"><xsl:copy-of select="$category" /></textarea>

    </ul>

    </div>

    </div>

         </li>

       </xsl:for-each>

     </ul>

    </div>

    </li>

    </xsl:template>

     

Please Sign in or register to post replies

Write your reply to:

Draft