Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
BrDan
Sry for the bad formatting - Tried to make it look better... :/
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']">
<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"/>
<div class="sub1 cf">
<xsl:if test="position() = '1'">
<xsl:attribute name="class">sub1 cf begin</xsl:attribute>
<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">
<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>
</li>
</xsl:for-each>
<textarea rows="8" cols="40"><xsl:copy-of select="$category" /></textarea>
</ul>
</xsl:template>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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:
This template renders each category, now I need to show childProducts.
Br
Dan
Sry for the bad formatting - Tried to make it look better... :/
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>
is working on a reply...