Note: Display 3 documentation is provided as a courtesy for clients on this legacy version of PowerReviews. It is no longer supported. We recommend contacting your Account Manager to discuss upgrading to our newer Display 4.1 version as soon as possible.
At times you might want to display a Web link instead of the review snippets in a product page. For example, if there are no reviews yet, you could display a link that says, 'Be the first to write a review.' The following code shows how to use the review display callback function, pr_data_callback, to determine the number of reviews a product has and then display the review snippets or a link, as appropriate:
<div id="hasReviews" style="display:none">
<div class="pr_snippet_product">
<script type="text/javascript">POWERREVIEWS.display.snippet(document, {
pr_page_id : 'abc123',
pr_read_review : '#ReviewHeader',
pr_write_review : 'http://www.yoursite.com/wrapper.jsp?pageId=abc123';
});
</script>
</div>
</div>
<div id="noReviews" style="display:none">
<script type="text/javascript">document.write('<a href='Be'>http://www.yoursite.com/wrapper.jsp?pageId=abc123'>Be the first to write a review </a>')
</script>
</div>
<script type="text/javascript">
var pr_page_id="abc123";
var pr_data_callback = function (info) {
if (info.getFullReviewCount() > 0) {
document.getElementById('hasReviews').style.display = "block";}
else {
document.getElementById('noReviews').style.display = "block";}
};
POWERREVIEWS.display.prData (pr_data_callback);
</script>