I was able to insert this code into my XML package and get it to display the stars, ratings, and text/links; however, my struggle is getting the links to work. We are using the tabbed format for the different sections of our product pages - including the reviews/ratings section so using <a href="#comments"> is not effective as it does nothing by way of navigating one to the Reviews tab. Any ideas on how to make that happen would be greatly appreciated! I am also struggling with getting the javascript link to work to open a new window to allow someone to create a new rating. It seems that I can either have it open a generic screen that is totally useless as it does not record the information - not linked to a particular product - OR it it simply will not do anything if I include a reference to any of the aspndsf predefined variables or xsl defined params/variables (i.e. ProductID or ProdID).
This section of code as I am using it follows. I am also including a few extra lines that were already part of this particular xml package as they may or may not cause a conflict - namely the queryparam="ProductID":
Code:
<query name="Products" rowElementName="Product">
<sql>
<![CDATA[
exec dbo.aspdnsf_ProductInfo @ProductID, @CustomerLevelID, @DefaultVariantOnly, 0, @affiliateID
]]>
</sql>
<queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
<queryparam paramname="@CustomerLevelID" paramtype="runtime" requestparamname="CustomerLevelID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@affiliateID" paramtype="system" requestparamname="AffiliateID" sqlDataType="int" defvalue="0" validationpattern="" />
<queryparam paramname="@DefaultVariantOnly" paramtype="runtime" requestparamname="DefaultVariantOnly" sqlDataType="int" defvalue="0" validationpattern="" />
</query>
<query name="Reviews" rowElementName="review">
<sql>
<![CDATA[
Select * FROM dbo.Rating WHERE ProductID = @prodID
]]>
</sql>
<queryparam paramname="@prodID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
</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="html" omit-xml-declaration="yes" />
<xsl:template match="Product">
<xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>
<xsl:param name="pDescription" select="aspdnsf:GetMLValue(Description)"></xsl:param>
<xsl:param name="pSalesPromptName" select="aspdnsf:GetMLValue(SalesPromptName)"></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="relatedProducts">
<xsl:value-of select="aspdnsf:RelatedProducts(ProductID, 0)" disable-output-escaping="yes"/>
</xsl:param>
<xsl:param name="upsellProducts">
<xsl:value-of select="aspdnsf:ShowUpsellProducts(ProductID)" disable-output-escaping="yes"/>
</xsl:param>
<xsl:param name="recentlyViewed">
<xsl:value-of select="aspdnsf:RecentlyViewed(ProductID, 0)" disable-output-escaping="yes"/>
</xsl:param>
<xsl:param name="alsoBought">
<xsl:value-of select="aspdnsf:AlsoBought(ProductID, VariantID)" disable-output-escaping="yes"/>
</xsl:param>
<xsl:param name="productRatings">
<xsl:value-of select="aspdnsf:ProductRatings(ProductID, 0, 0, 0, 0, 0)" disable-output-escaping="yes"/>
</xsl:param>
<xsl:param name="productReview">
<xsl:value-of select="aspdnsf:ProductRatings(ProductID, 0, 0, 0, 0, 0)" disable-output-escaping="yes"/>
</xsl:param>
<xsl:param name="score">
<xsl:choose>
<xsl:when test="count(/root/Reviews/review) >0">
<xsl:value-of select="sum(/root/Reviews/review/Rating) div count(/root/Reviews/review)" />
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="prodID"><xsl:value-of select="/root/Runtime/ProductID" /></xsl:param>
<xsl:param name="RequestedPage"><xsl:value-of select="/root/System/RequestedPage" /></xsl:param>
<script type="text/javascript" language="javascript">
<![CDATA[
function RateProd(pid)
{
window.open('http://www.got-chrome.com/rateit.aspx?Productid='+ProductID);
}
]]>
</script>
<!-- New section - Product Rating Stars with link to Product Rating Info -->
<xsl:choose>
<xsl:when test="count(/root/Reviews/review) >0">
<div style="float:right;text-align:right;font-size:1.1em;">
<a href="#comments"><xsl:value-of select="aspdnsf:GetRatingStarsImage($score)" disable-output-escaping="yes" />
: Current Rating <xsl:value-of select='format-number($score, "#.#")' />/5</a> <font color="red"><strong><br />NEW </strong></font><a href="javascript:;" onclick="RateProd($ProductID);">Write Review</a> | <a href="#comments">Read Reviews</a>
<br style="clear:both;" /><br />
</div>
</xsl:when>
<xsl:otherwise>
<div style="font-size:1.1em">
<a href="#comments"><xsl:value-of select="aspdnsf:GetRatingStarsImage($score)" disable-output-escaping="yes" />
: No Ratings Yet</a>
<br style="clear:both;" /><br />
<a href="{concat('javascript:RateProd(',$prodID,');')}"><font color="red"><strong>NEW</strong></font> Review This Product</a>
</div>
</xsl:otherwise>
</xsl:choose>
Here is an example of a page where I have the stars and basics working using a test skin:
http://www.got-chrome.com/p-3369-152....aspx?skinid=5
Any assistance will be greatly appreciated!
~Tonya