Is there a way to get the reviews to sit on the main product page? Ideally so visitors can click a reviews tab and see the reviews hosted on the same page and then go back to the prices?
Edit includes/tapestry.php and look for the following code at line 74:
function tapestry_reviewHREF($product)
{
global $config_baseHREF;
global $config_useRewrite;
if ($config_useRewrite)
{
return $config_baseHREF."review/".urlencode(tapestry_hyphenate($product["normalised_name"])).".html";
}
else
{
return $config_baseHREF."reviews.php?q=".urlencode($product["normalised_name"]);
}
}
...and REPLACE with:
function tapestry_reviewHREF($product)
{
return tapestry_productHREF($product)."#reviews";
}
Edit html/default.css and add the following new rules to style the tabs:
Hi Chris,
To merge reviews with the products page using Foundation's tabs class, have a go with the following;
Edit products.php and look for the following code at line 6:
$rewrite = isset($_GET["rewrite"]);
...and REPLACE with:
$rewrite = isset($_GET["rewrite"]);
if (isset($_POST["submit"]))
{
if (!isset($_POST["comments"])) $_POST["comments"] = "";
if ($_POST["rating"] && ($_POST["rating"] == $_POST["confirm"]))
{
$sql = "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='0',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."'";
database_queryModify($sql,$insertId);
}
header("Location: ?pending=1#reviews");
exit();
}
Then look for the following code at (now) line 49:
if ($rows[$k]["reviews"])
{
$rows[$k]["extraHTML"] = "<p>".tapestry_stars($rows[$k]["rating"],"")." <a href='".$rows[$k]["reviewHREF"]."'>".$rows[$k]["reviews"]." ".translate("Reviews")."</a></p>";
}
else
{
$rows[$k]["extraHTML"] = "<p><a href='".$rows[$k]["reviewHREF"]."'>".translate("Review This Product")."</a></p>";
}
...and REPLACE with:
if ($rows[$k]["reviews"])
{
$rows[$k]["extraHTML"] = "<p>".tapestry_stars($rows[$k]["rating"],"")." <a href='JavaScript:reviewsClick();'>".$rows[$k]["reviews"]." ".translate("Reviews")."</a></p>";
}
else
{
$rows[$k]["extraHTML"] = "<p><a href='JavaScript:reviewsClick();'>".translate("Review This Product")."</a></p>";
}
And finally the following code at (now) line 173:
if (isset($prices)) require("html/prices.php");
...and REPLACE with
if (isset($prices))
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."reviews` WHERE product_name = '".database_safe($q)."' AND approved <> '0' ORDER BY created";
if (database_querySelect($sql,$rows))
{
$ratings["reviews"] = $rows;
}
?>
<div class='row'>
<div class='small-12 columns'>
<dl class="tabs" data-tab>
<dd class="tab-title active" id='t1'> <a href="#prices">Compare Prices</a></dd>
<dd class="tab-title" id="t2"> <a href="#reviews">Reviews</a></dd>
</dl>
<div class="tabs-content">
<div class="content active" id="prices">
<?php require("html/prices.php"); ?>
</div>
<div class="content" id="reviews">
<?php require("html/ratings.php"); ?>
</div>
</div>
</div>
</div>
<script type='text/JavaScript'>
function reviewsClick()
{
$("#t1").removeClass("active");
$("#t2").addClass("active");
$("#prices").removeClass("active");
$("#reviews").addClass("active");
}
if(window.location.hash == "#reviews")
{
reviewsClick();
}
</script>
<?php
}
Edit includes/tapestry.php and look for the following code at line 74:
function tapestry_reviewHREF($product)
{
global $config_baseHREF;
global $config_useRewrite;
if ($config_useRewrite)
{
return $config_baseHREF."review/".urlencode(tapestry_hyphenate($product["normalised_name"])).".html";
}
else
{
return $config_baseHREF."reviews.php?q=".urlencode($product["normalised_name"]);
}
}
...and REPLACE with:
function tapestry_reviewHREF($product)
{
return tapestry_productHREF($product)."#reviews";
}
Edit html/default.css and add the following new rules to style the tabs:
.tab-title a {
background-color: #fff !important;
border: 1px solid #aaa;
border-width: 1px 1px 1px 1px;
border-radius: 5px 5px 0 0;
margin-right: 5px;
height: 60px;
padding: 5px 15px 5px 15px !important
;
}
.tab-title.active a {
border-bottom: 1px solid #fff;
}
.tabs-content {
border: 1px solid #aaa;
padding: 0px;
}
.content {
margin: 0px !important;
padding: 15px !important;
}
.content>p {
margin: 0px !important;
padding: 0px !important;
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com