News:

Looking for documentation? Take a look on our wiki

Main Menu

Product page URL

Started by driver_wedge, July 25, 2017, 18:32:32 PM

Previous topic - Next topic

driver_wedge

Hi guys...

On the category pages for my site, you can click on either the product image or a Product Details button to visit the product page. The image is linked to www.mysite.com/menu-item-alias/product-alias-detail - whereas the Product Details button goes to www.mysite.com/component/virtuemart/product-alias-detail?Itemid=100

The button is created via this code in /template/html/com_virtuemart/sublayouts/addtocartbar.php

<a class="btn btn-default" href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id); ?>"><?php echo vmText::_ ('VIEW PRODUCT') ?></a>

Can anyone advise on the route I should add to the button so as to achieve the same URL as the product image?

Hope that makes sense.

Thanks!

jenkinhill

IN the default VM template sublayouts the URLS are the same, so suggest you compare your override with that.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

driver_wedge

Ok, awesome.....good suggestion! Many thanks!

driver_wedge

Sorry! Back again...

I can't work it out unfortunately. Do you know which file controls the product image on the Category page? Maybe I can locate that within the template and add the same link format to the 'Product Details' button.

jenkinhill

components/com_virtuemart/sublayouts/products.php
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

driver_wedge

I finally managed to sort this with the following code from the products.php file.

Thanks for your help!

-------------------------------------------

<div class="vm-details-button">
            <?php // Product Details Button
            $link = empty($product->link)? $product->canonical:$product->link;
            echo JHtml::link($link.$ItemidStr,vmText::_ ( 'COM_VIRTUEMART_PRODUCT_DETAILS' ), array ('title' => $product->product_name, 'class' => 'product-details' ) );
            //echo JHtml::link ( JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id , FALSE), vmText::_ ( 'COM_VIRTUEMART_PRODUCT_DETAILS' ), array ('title' => $product->product_name, 'class' => 'product-details' ) );
            ?>
</div>