Good day
I already add this code to productdetails/default.php and it works perfect,
<h1 class="product-title" id="compatible-products">
<?php echo JText::_ ('COM_VIRTUEMART_ALSO_IN_CATEGORY') ?></h1>
<?php
function sortByOption($a, $b) {
return strcmp($a['category_name'], $b['category_name']);
}
usort($this->product->categoryItem, "sortByOption");
?>
<?php $categories=$this->product->categoryItem;
foreach ($categories as $category){
$caturl = JRoute::_ ( 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category['virtuemart_category_id'] );
$catname=$category['category_name'];
echo '<a href="'.$caturl.'" title="'.$catname.'">'.$catname.'</a> , ';
}
?>
But when i try to add it to product.php in sublayout it destroy my page, it dosent work, any clue what is wrong ?
Stefan
use $product-> instead of
$this->product->
Quote from: GJC Web Design on February 09, 2021, 18:04:06 PM
use $product-> instead of
$this->product->
Thanks GJC
now it work in some part, the layout of the page is destroy , and it shows all categories the product belong to only for the first product not all products that are on page ;(
Any clue ?
I have remove my sorting code and now works ok, any clue why this code destroy that page ?
<?php
function sortByOption($a, $b) {
return strcmp($a['category_name'], $b['category_name']);
}
usort($product->categoryItem, "sortByOption");
?>