Code:
<?xml version="1.0" standalone="yes" ?>
<package version="2.1" displayname="Entity Grid" debug="false" includeentityhelper="true">
<!-- ###################################################################################################### -->
<!-- Copyright AspDotNetStorefront.com, 1995-2009. All Rights Reserved. -->
<!-- http://www.aspdotnetstorefront.com -->
<!-- For details on this license please visit the product homepage at the URL above. -->
<!-- THE ABOVE NOTICE MUST REMAIN INTACT. -->
<!-- -->
<!-- ###################################################################################################### -->
<query name="Products" rowElementName="Product">
<sql>
<![CDATA[
exec dbo.aspdnsf_GetProducts
@categoryID = @CatID,
@sectionID = @SecID,
@manufacturerID = @ManID,
@distributorID = @DistID,
@genreID = @GenreID,
@vectorID = @VectorID,
@localeName = @locale,
@CustomerLevelID = @CustLevelID,
@affiliateID = @AffID,
@ProductTypeID = @ProdTypeID,
@ViewType = 1,
@pagenum = @pgnum,
@pagesize = null,
@StatsFirst = 0,
@publishedonly = 1,
@ExcludePacks = 0,
@ExcludeKits = 0,
@ExcludeSysProds = 0,
@InventoryFilter = @InvFilter,
@sortEntityName = @entityname
]]>
</sql>
<queryparam paramname="@CatID" paramtype="runtime" requestparamname="CatID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@SecID" paramtype="runtime" requestparamname="SecID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@ManID" paramtype="runtime" requestparamname="ManID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@DistID" paramtype="runtime" requestparamname="DistID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@GenreID" paramtype="runtime" requestparamname="GenreID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@VectorID" paramtype="runtime" requestparamname="VectorID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@locale" paramtype="runtime" requestparamname="LocaleSetting" sqlDataType="varchar" defvalue="en-US" validationpattern="" />
<queryparam paramname="@CustLevelID" paramtype="runtime" requestparamname="CustomerLevelID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@AffID" paramtype="runtime" requestparamname="AffiliateID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@ProdTypeID" paramtype="runtime" requestparamname="ProductTypeFilterID" sqlDataType="int" defvalue="1" validationpattern="" />
<queryparam paramname="@pgnum" paramtype="request" requestparamname="pagenum" sqlDataType="int" defvalue="1" validationpattern="" />
<queryparam paramname="@InvFilter" paramtype="appconfig" requestparamname="HideProductsWithLessThanThisInventoryLevel" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@entityname" paramtype="runtime" requestparamname="EntityName" sqlDataType="varchar" defvalue="" validationpattern="" />
</query>
<query name="EntityProducts" rowElementName="Product">
<sql>
<![CDATA[
SELECT pv.[ProductID] AS [EntityProductID], COUNT([pv].[VariantID]) AS [NumVariants]
FROM [Product{EntityName}] AS pe WITH (NOLOCK)
JOIN [ProductVariant] AS pv WITH (NOLOCK) ON [pe].[ProductID] = [pv].[ProductID]
JOIN [Product] AS p WITH (NOLOCK) ON [p].[ProductID] = [pv].[ProductID]
JOIN [{EntityName}] AS e WITH (NOLOCK) ON [e].[{EntityName}ID] = [pe].[{EntityName}ID]
WHERE pe.[{EntityName}ID] = @EntityID
AND [pv].[Deleted] = 0 AND [pv].[Published] = 1
AND [p].[Deleted] = 0 AND [p].[Published] = 1
AND [e].[Deleted] = 0 AND [e].[Published] = 1
GROUP BY [pv].[ProductID]
]]>
</sql>
<queryparam paramname="@EntityID" paramtype="runtime" requestparamname="EntityID" sqlDataType="int" defvalue="0" validationpattern="" />
<querystringreplace replaceTag="{EntityName}" replacetype="runtime" replaceparamname="EntityName" defvalue="" validationpattern="(category)|(section)" />
</query>
<query name="ese" rowElementName="maxEntityDiscount">
<sql>
<![CDATA[
SELECT [{EntityName}ID] AS [EntityID], [ExtensionData]
FROM [{EntityName}] WITH (NOLOCK)
WHERE [Parent{EntityName}ID] = @EntityID
AND ExtensionData IS NOT NULL
]]>
</sql>
<queryparam paramname="@EntityID" paramtype="runtime" requestparamname="EntityID" sqlDataType="int" defvalue="0" validationpattern="" />
<querystringreplace replaceTag="{EntityName}" replacetype="runtime" replaceparamname="EntityName" defvalue="" validationpattern="(category)|(section)" />
</query>
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="LocaleSetting" select="/root/Runtime/LocaleSetting" />
<xsl:param name="WebConfigLocaleSetting" select="/root/Runtime/WebConfigLocaleSetting" />
<xsl:param name="ShowSubcatsInGrid"><xsl:value-of select="aspdnsf:AppConfig('ShowSubcatsInGrid')" /></xsl:param>
<xsl:param name="SubcatGridCols"><xsl:value-of select="/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[EntityID=/root/Runtime/EntityID]/ColWidth" /></xsl:param>
<xsl:param name="EntityName"><xsl:value-of select="/root/Runtime/EntityName" /></xsl:param>
<xsl:param name="EntityID"><xsl:value-of select="/root/Runtime/EntityID" /></xsl:param>
<xsl:param name="WholesaleOnlySite"><xsl:value-of select="aspdnsf:AppConfigBool('WholesaleOnlySite')"/></xsl:param>
<xsl:param name="Summary"><xsl:value-of select="/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[EntityID=/root/Runtime/EntityID]/EntityID" /></xsl:param>
<xsl:param name="BaseURL">
<xsl:choose>
<xsl:when test="aspdnsf:StrToLower(/root/Runtime/EntityName) = 'category'">c-<xsl:value-of select="/root/Runtime/EntityID" />-<xsl:value-of select="/root/QueryString/sename" />.aspx</xsl:when>
<xsl:when test="aspdnsf:StrToLower(/root/Runtime/EntityName) = 'section'">s-<xsl:value-of select="/root/Runtime/EntityID" />-<xsl:value-of select="/root/QueryString/sename" />.aspx</xsl:when>
<xsl:when test="aspdnsf:StrToLower(/root/Runtime/EntityName) = 'manufacturer'">m-<xsl:value-of select="/root/Runtime/EntityID" />-<xsl:value-of select="/root/QueryString/sename" />.aspx</xsl:when>
<xsl:when test="aspdnsf:StrToLower(/root/Runtime/EntityName) = 'library'">l-<xsl:value-of select="/root/Runtime/EntityID" />-<xsl:value-of select="/root/QueryString/sename" />.aspx</xsl:when>
<xsl:when test="aspdnsf:StrToLower(/root/Runtime/EntityName) = 'distributor'">d-<xsl:value-of select="/root/Runtime/EntityID" />-<xsl:value-of select="/root/QueryString/sename" />.aspx</xsl:when>
</xsl:choose>
</xsl:param>
<xsl:param name="CurrentPage">
<xsl:choose>
<xsl:when test="/root/QueryString/pagenum"><xsl:value-of select="/root/QueryString/pagenum" /></xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="ParentSectionID">
<xsl:value-of select="/root/EntityHelpers/Section/Entity/Entity[EntityID=$EntityID]/ParentEntityID"/>
</xsl:param>
<xsl:template match="/">
<h1><xsl:value-of select="aspdnsf:GetMLValue(/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[EntityID=/root/Runtime/EntityID]/Name)" disable-output-escaping="yes" /></h1>
<xsl:value-of select="aspdnsf:EntityPageFilterOptions($EntityName, $EntityID, /root/Runtime/SecID, /root/Runtime/CatID, /root/Runtime/ManID, /root/Runtime/ProductTypeFilterID)" disable-output-escaping="yes" />
<xsl:call-template name="SubEntity" />
<xsl:choose>
<xsl:when test="count(/root/Products/Product) = 0 and count(/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[EntityID=/root/Runtime/EntityID]/Entity) = 0">
<xsl:value-of select="aspdnsf:Topic(concat('empty', /root/Runtime/EntityName, 'text'))" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
<xsl:if test="count(/root/Products/Product) > 0">
<xsl:if test="/root/Products2/Product/pages > 1">
<div style="text-align:right; font-size:small;"><xsl:value-of select="aspdnsf:PagingControl($BaseURL, $CurrentPage, /root/Products2/Product/pages)" disable-output-escaping="yes" /></div>
</xsl:if>
<table border="0" cellpadding="0" cellspacing="4" width="100%">
<xsl:apply-templates select="/root/Products/Product" />
</table>
<xsl:if test="aspdnsf:StrToLower($EntityName) = 'section' and count(/root/EntityHelpers/Section/Entity[EntityID=$ParentSectionID]/Entity/Name) > 1">
<div class="eseRelatedSections">
Other sections in <strong><xsl:value-of select="/root/EntityHelpers/Section/Entity[EntityID=$ParentSectionID]/Name" disable-output-escaping="yes" /></strong>:
<ul>
<xsl:for-each select="/root/EntityHelpers/Section/Entity/Entity">
<xsl:if test="ParentEntityID = /root/EntityHelpers/Section/descendant::Entity[EntityID=$EntityID]/ParentEntityID and not(Name = /root/EntityHelpers/Section/descendant::Entity[EntityID=$EntityID]/Name)">
<li>
<a href="{concat('s-',EntityID,'-',SEName,'.aspx')}"><xsl:value-of select="Name" disable-output-escaping="yes" /></a>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</div>
</xsl:if>
<xsl:if test="/root/Products2/Product/pages > 1">
<div style="text-align:right; font-size:small;"><xsl:value-of select="aspdnsf:PagingControl($BaseURL, $CurrentPage, /root/Products2/Product/pages)" disable-output-escaping="yes" /></div>
</xsl:if>
</xsl:if>
<div class="eseEntityDescription">
<xsl:value-of select="aspdnsf:EntityPageHeaderDescription($EntityName, $EntityID)" disable-output-escaping="yes" />
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="SubEntity">
<xsl:variable name="delta">
<xsl:choose>
<xsl:when test="(count(/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]) mod number($SubcatGridCols)) = 0">0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($SubcatGridCols)-(count(/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]) mod number($SubcatGridCols))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rows" select="ceiling(count(/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]) div number($SubcatGridCols))" />
<xsl:for-each select="/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]">
<xsl:variable name="entityposition" select="position()" />
<xsl:choose>
<xsl:when test="$ShowSubcatsInGrid = 'true'">
<xsl:if test="position() mod $SubcatGridCols = 1 or ($SubcatGridCols = 1)">
<table border="0" cellpadding="0" cellspacing="4" width="100%">
<tr>
<xsl:for-each select=". | following-sibling::*[position() < $SubcatGridCols]">
<xsl:variable name="scName" select="aspdnsf:GetMLValue(Name)"></xsl:variable>
<xsl:call-template name="SubCatCell">
<xsl:with-param name="scName" select="$scName" />
</xsl:call-template>
</xsl:for-each>
<xsl:if test="ceiling($entityposition div number($SubcatGridCols)) = $rows and $delta > 0">
<xsl:call-template name="FillerCells">
<xsl:with-param name="cellCount" select="$delta" />
</xsl:call-template>
</xsl:if>
</tr>
<tr>
<td height="10" colspan="{$SubcatGridCols}"> </td>
</tr>
</table>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="scName" select="aspdnsf:GetMLValue(Name)"></xsl:variable>
<p align="left">
   <img border="0" src="{concat('skins/skin_', aspdnsf:SkinID(), '/images/redarrow.gif')}"></img> 
<a href="{aspdnsf:EntityLink(EntityID, SEName, $EntityName, 0, '')}">
<xsl:value-of select="$scName" disable-output-escaping="yes"/>
</a>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="SubCatCell">
<xsl:param name="scName"></xsl:param>
<xsl:param name="pSEAltText" select="aspdnsf:GetMLValue(SEAltText)"></xsl:param>
<xsl:param name="AltText">
<xsl:choose>
<xsl:when test="$pSEAltText=''"><xsl:value-of select="$scName" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$pSEAltText" /></xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="saveEntityID" select="EntityID"></xsl:param>
<xsl:param name="URL"><xsl:value-of select="aspdnsf:EntityLink(EntityID, SEName, $EntityName, 0, '')" /></xsl:param>
<td align="center" width="{concat(round(100 div number($SubcatGridCols)),'%')}" style="border: 1px solid #ddd;width:200px">
<div class="eseFeaturedImageSections">
<a href="{$URL}">
<xsl:value-of select="aspdnsf:LookupEntityImage(EntityID, $EntityName, 'icon', 0, $AltText)" disable-output-escaping="yes" />
<xsl:for-each select="/root/ese/maxEntityDiscount">
<xsl:call-template name="EntityPage">
<xsl:with-param name="saveEntityID" select="$saveEntityID" />
</xsl:call-template>
</xsl:for-each>
</a>
</div>
<br/>
<h2 class="eseH2">
<a href="{$URL}">
<xsl:value-of select="$scName" disable-output-escaping="yes"/>
</a>
</h2>
</td>
</xsl:template>
<xsl:template name="EntityPage">
<xsl:param name="saveEntityID"></xsl:param>
<xsl:if test="$saveEntityID=EntityID and ExtensionData != ''">
<xsl:if test="contains(ExtensionData, 'maxDiscount')">
<div style="position: absolute; top: 100px; left: 100px;">
<img src="{concat('skins/Skin_1/images/discount-small-',aspdnsf:XmlStringAsXml(ExtensionData, 'maxDiscount'),'.png')}" width="52" height="52"></img>
</div>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="Product">
<xsl:variable name="delta">
<xsl:choose>
<xsl:when test="(count(/root/Products/Product) mod number($SubcatGridCols)) = 0">0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($SubcatGridCols)-(count(/root/Products/Product) mod number($SubcatGridCols))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rows" select="ceiling(count(/root/Products/Product) div number($SubcatGridCols))" />
<xsl:if test="$SubcatGridCols = 1">
<tr>
<xsl:call-template name="ProductCell"></xsl:call-template>
</tr>
</xsl:if>
<xsl:if test="position() mod $SubcatGridCols = 1 and $SubcatGridCols > 1">
<tr>
<xsl:for-each select=". | following-sibling::*[position() < $SubcatGridCols]">
<xsl:call-template name="ProductCell"></xsl:call-template>
</xsl:for-each>
<xsl:if test="ceiling(position() div number($SubcatGridCols)) = $rows and $delta > 0">
<xsl:call-template name="FillerCells">
<xsl:with-param name="cellCount" select="$delta" />
</xsl:call-template>
</xsl:if>
</tr>
</xsl:if>
</xsl:template>
<xsl:template name="ProductCell">
<xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>
<xsl:param name="pSEAltText" select="aspdnsf:GetMLValue(SEAltText)"></xsl:param>
<xsl:param name="AltText">
<xsl:choose>
<xsl:when test="$pSEAltText=''"><xsl:value-of select="$pName" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$pSEAltText" /></xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="saveProductID" select="ProductID"></xsl:param>
<td align="center" valign="top" width="{concat(round(100 div number($SubcatGridCols)),'%')}">
<table>
<tr>
<td height="30" align="center" valign="middle" style="border: 1px solid #ddd;width:200px">
<div class="eseFeaturedImageSections">
<a href="{aspdnsf:ProductandEntityLink(ProductID, SEName, $EntityID, $EntityName, 0)}" title="{$AltText}" id="s{ProductID}">
<img src="{concat('/images/product/icon/',ProductID,'.jpg')}" width="150" height="150" alt="{$AltText}" title="{$AltText}" />
</a>
<xsl:if test="DiscountSticker != '' and DiscountSticker != '0'">
<div style="position: absolute; top: 90px; left: 80px;">
<a href="{aspdnsf:ProductandEntityLink(ProductID, SEName, $EntityID, $EntityName, 0)}">
<img src="{concat('skins/Skin_1/images/discount-small-',DiscountSticker,'.png')}"></img>
</a>
</div>
</xsl:if>
</div>
</td>
</tr>
<tr>
<td height="10" align="center" valign="top">
<a href="{aspdnsf:ProductandEntityLink(ProductID, SEName, $EntityID, $EntityName, 0)}" title="{$AltText}">
<xsl:value-of select="$pName" disable-output-escaping="yes" />
</a>
<br />
Prices from: <xsl:value-of select="DiscountedPrice" disable-output-escaping="yes" /> (ex. VAT)
</td>
</tr>
<tr>
<td height="45" align="center" valign="top">
<xsl:if test="aspdnsf:AppConfigBool('DisplayOutOfStockProducts') = 'true'">
<xsl:value-of select="aspdnsf:DisplayProductStockHint(ProductID, VariantID,'Entity')" disable-output-escaping="yes" />
</xsl:if>
</td>
</tr>
<tr>
<td>
<xsl:for-each select="/root/EntityProducts/Product" >
<xsl:call-template name="EntityProduct">
<xsl:with-param name="saveProductID" select="$saveProductID" />
<xsl:with-param name="EntityID" select="$EntityID" />
<xsl:with-param name="EntityName" select="$EntityName" />
</xsl:call-template>
</xsl:for-each>
</td>
</tr>
</table>
</td>
</xsl:template>
<xsl:template name="EntityProduct">
<xsl:param name="saveProductID"></xsl:param>
<xsl:param name="EntityID"></xsl:param>
<xsl:param name="EntityName"></xsl:param>
<xsl:if test="EntityProductID=$saveProductID">
<a href="{aspdnsf:ProductandEntityLink($saveProductID, '', $EntityID, $EntityName, 0)}">
This product has <xsl:value-of select="NumVariants" disable-output-escaping="yes" /> options!</a>
</xsl:if>
</xsl:template>
<xsl:template name="FillerCells">
<xsl:param name="cellCount"/>
<xsl:param name="CellWidth" select="100 div $SubcatGridCols" />
<td width="{$CellWidth}%"> </td>
<xsl:if test="$cellCount > 1">
<xsl:call-template name="FillerCells">
<xsl:with-param name="cellCount" select="$cellCount - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
</PackageTransform>
</package>