Quote:
- lastly when a product is clicked on the same menu structure needs be displayed as when the sub category is clicked
|
I was able to figure out this last requirement by going to the product.php file in the xcart root folder and adding the code below. I discovered I had to add this before the $smarty->assign of $product_info to be able to use its value.
PHP Code:
$smarty->assign("sub_categories_nav", func_query("SELECT categoryid, category FROM xcart_categories WHERE parentid = (SELECT parentid FROM xcart_categories WHERE categoryid = ".$product_info['categoryid'].") ORDER BY categoryid ASC"));
$smarty->assign("sub_category_products", func_query("SELECT ple.productid, ple.product FROM xcart_products_lng_en AS ple INNER JOIN xcart_products_categories AS pc ON ple.productid = pc.productid WHERE pc.categoryid = ".$product_info['categoryid']." ORDER BY ple.productid ASC"));
$smarty->assign('product', $product_info);
Then in my custom product_pages_nav_create.tpl my code is:
Code:
{foreach from=$sub_categories_nav item=subcat name=subcategories_nav}
<div class="subcategories_nav"{interline name=subcategories_nav}>
» <a href="home.php?cat={$subcat.categoryid}">{$subcat.category|escape}</a>
</div>
{if $product.categoryid eq $subcat.categoryid}
<ul class="subcategories_prod">
{foreach from=$sub_category_products item=subcat_prod name=subcategories_prod}
<li{interline name=subcategories_prod}>
» <a href="home.php?cat={$subcat_prod.productid}">{$subcat_prod.product|escape}</a>
</li>
{/foreach}
</ul>
{/if}
{/foreach}