I have the statement if(isset($votes))
in votes_allvotes.tpl.php.
If I check the value on the same line right before that statement it tells me the value is 2, but for some reason the if statement refuses to acknowledge this.
Also tried if($votes > 0), did not work. I use this on 2 pages and on the other one it works fine, though there is nothing on this page that should conflict in any way with this (deleted everything on the page and it still didnt work.
Using Joomla 1.5.21 and Virtuemart 1.1.6
Here is the code:
<div class="rating" style="margin: 0px 0px 15px -9px">
<?php
$product_flypage = $_SERVER['REQUEST_URI'];
echo ps_reviews::allvotes( $product_flypage );
?>
ps_reviews::allvotes:
function allvotes( $product_id ) {
if (strstr($product_id, '&')) {
$arr = explode('&', $product_id);
$pro_arr = explode('=', $arr[2]);
$cat_arr = explode('=', $arr[3]);
$product_id = $pro_arr[1];
$category_id = $cat_arr[1];
}
global $db;
$tpl = new $GLOBALS['VM_THEMECLASS']();
$dbc = new ps_DB;
$q = "SELECT votes, rating FROM #__{vm}_product_votes "
. "WHERE product_id='$product_id' ";
$dbc->query( $q );
$votes = $dbc->f("votes");
$rating = $dbc->f("rating");
if( $votes != 0)
$tpl->set('votes', $votes );
$tpl->set('rating', $rating );
$tpl->set('product_id', $product_id );
$tpl->set('category_id', $category_id );
return $tpl->fetch( 'common/votes_allvotes.tpl.php' );
}
votes_allvotes.tpl.php (WHERE THE ACTUAL PROBLEM IS):
if (isset($votes)) { ?>
<img src="<?php echo VM_THEMEURL ?>images/stars/<?php echo $rating ?>.gif" align="middle" border="0" alt="<?php echo $rating ?> stars" />
<?php echo $VM_LANG->_('PHPSHOP_TOTAL_VOTES').": ". $votes;
}
else {
if (!empty($my->id)) {
if( $_GET['flypage']){
echo "<li class='reviews'><a href='javascript:void(0)' style='color:#000;'><b>Wees de eerste om een recensie te schrijven!</b></a></li>";
}else{
echo "<a href='/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=". $product_id ."&category_id=". $category_id ."&option=com_virtuemart&Itemid=1&lang=nl&review=yes'><b>Wees de eerste om een recensie te schrijven!</b></a>";
}
}else {
echo $VM_LANG->_('PHPSHOP_REVIEW_LOGIN'); // Login to write a review!
}
}