Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 7 of 7

Thread: Question About Reviews and Ratings

  1. #1
    peter3827 is offline Senior Member
    Join Date
    Nov 2005
    Posts
    281

    Default Question About Reviews and Ratings

    Is it possible to move just the stars below the Product Name and keep the posting review part at the bottom of the page? If it is can someone direct me in the right direction? We are using 9.1. Any help will do. Thanks.

  2. #2
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    You can access the data directly in an xmlpackage & output it to the screen however you like. Take a look at 3M Select to see an example of what I've done...


    Homepage - just the stars under each featured product.

    Category page - Again, just the stars.

    Product Page - Stars at the top & comments at the bottom.



    TTFN

    BFG

  3. #3
    peter3827 is offline Senior Member
    Join Date
    Nov 2005
    Posts
    281

    Default

    That's awesome! What xml package are you taking about?

  4. #4
    peter3827 is offline Senior Member
    Join Date
    Nov 2005
    Posts
    281

    Default

    Any direction would be greatly appreciated.

  5. #5
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    It's a custom xmlpackage - it looks like this :-


    C#/VB.NET Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" allowengine="true" displayname="Stars" debug="false" includeentityhelper="false">

        <!-- ###################################################################################################### -->
        <!-- Copyright AspDotNetStorefront.com, 1995-2008.  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="Reviews" rowElementName="review">
            <sql>
                <![CDATA[

    Select * FROM dbo.Rating WHERE ProductID = @ProductID

                ]]>
            </sql>

            <queryparam paramname="@ProductID" 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="/">

    <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="ProductID"><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(ProductID)
                        {
                            window.open('x-product-review.aspx?pid=' + ProductID + '&refresh=no','AspDotNetStorefront_ML','height=500,width=500,top=10,left=20,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no');
                        }
                    ]]>
                    </script> 
    <xsl:choose>
    <xsl:when test="count(/root/Reviews/review) >0">

    <div style="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>
    <br /><br />
    <font color="red"><strong>NEW </strong></font><a href="{concat('javascript:RateProd(',$ProductID,');')}">Write Review</a> | <a href="#comments">Read Reviews</a>
    </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 /><br />
    <a href="{concat('javascript:RateProd(',$ProductID,');')}"><font color="red"><strong>NEW</strong></font> Review This Product</a>
    </div>

    </xsl:otherwise>
    </xsl:choose>

    </xsl:template>





            </xsl:stylesheet>
        </PackageTransform>
    </package>

    You'll need to tweak it - but it will give you the idea - just call it within your product xmlpackage where you'd like the stars to show up...


    TTFN

    BFG

  6. #6
    peter3827 is offline Senior Member
    Join Date
    Nov 2005
    Posts
    281

    Default

    Thanks for your help!!

  7. #7
    tonya is offline Junior Member
    Join Date
    Sep 2011
    Posts
    22

    Default Using ML v.8 & Struggling with Getting This Code to Work

    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