EDIT: Versions of Joomla 3.9.1, version of Virtuemart 3.4.2. Sorry for the confusion.
Hi,
I'm not sure I'm in the correct place of the forum, sorry if I missed it.
I want to remove the links to "product details" both from the link, and the thumbnail, that I see on the category view (well, I think is called category view). I would be happy too with changing the links to other pages of my site, on a product by product property (but adding it to the "URL" field in the product creation does absolutely nothing).
You can see what I want to edit here: https://www.sherpaexpert.com/index.php/selector-de-escaleras/ (I use virtuemart as a catalogue, and currently only have 2 items for simplicity).
Trying to do that, I created a template override of "/html/com_virtuemart/category/default.php".
<?php
/**
*
* Show the products in a category
*
* @package VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link https://virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 9942 2018-09-27 11:54:06Z junstoppable $
*/
defined ('_JEXEC') or die('Restricted access');
if (vRequest::getInt('dynamic',false) and vRequest::getInt('virtuemart_product_id',false)) {
if (!empty($this->products)) {
if($this->fallback){
$p = $this->products;
$this->products = array();
$this->products[0] = $p;
vmdebug('Refallback');
}
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
}
return ;
}
?> <div class="category-view"> <?php
$js = "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
";
vmJsApi::addJScript('vm-hover',$js);
if ($this->show_store_desc and !empty($this->vendor->vendor_store_desc)) { ?>
<div class="vendor-store-desc">
<?php echo $this->vendor->vendor_store_desc; ?>
</div>
<?php }
if (!empty($this->showcategory_desc) and empty($this->keyword)){
if(!empty($this->category)) {
?>
<div class="category_description">
<?php echo $this->category->category_description; ?>
</div>
<?php }
if(!empty($this->manu_descr)) {
?>
<div class="manufacturer-description">
<?php echo $this->manu_descr; ?>
</div>
<?php }
}
// Show child categories
if ($this->showcategory and empty($this->keyword)) {
if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
}
}
if (!empty($this->products) or ($this->showsearch or $this->keyword !== false)) {
?>
<div class="browse-view">
<?php
if ($this->showsearch or $this->keyword !== false) {
//id taken in the view.html.php could be modified
$category_id = vRequest::getInt ('virtuemart_category_id', 0); ?>
<!--BEGIN Search Box -->
<div class="virtuemart_search">
<form action="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=category&limitstart=0', FALSE); ?>" method="get">
<?php if(!empty($this->searchCustomList)) { ?>
<div class="vm-search-custom-list">
<?php echo $this->searchCustomList ?>
</div>
<?php } ?>
<?php if(!empty($this->searchCustomValues)) { ?>
<div class="vm-search-custom-values">
<?php
echo ShopFunctionsF::renderVmSubLayoutAsGrid(
'searchcustomvalues',
array (
'searchcustomvalues' => $this->searchCustomValues,
'options' => array (
'items_per_row' => array (
'xs' => 2,
'sm' => 2,
'md' => 2,
'lg' => 2,
'xl' => 2,
),
),
)
);
?>
</div>
<?php } ?>
<div class="vm-search-custom-search-input">
<input name="keyword" class="inputbox" type="text" size="40" value="<?php echo $this->keyword ?>"/>
<input type="submit" value="<?php echo vmText::_ ('COM_VIRTUEMART_SEARCH') ?>" class="button" onclick="this.form.keyword.focus();"/>
<?php //echo VmHtml::checkbox ('searchAllCats', (int)$this->searchAllCats, 1, 0, 'class="changeSendForm"'); ?>
<span class="vm-search-descr"> <?php echo vmText::_('COM_VM_SEARCH_DESC') ?></span>
</div>
<!-- input type="hidden" name="showsearch" value="true"/ -->
<input type="hidden" name="view" value="category"/>
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="virtuemart_category_id" value="<?php echo $category_id; ?>"/>
<input type="hidden" name="Itemid" value="<?php echo $this->Itemid; ?>"/>
</form>
</div>
<!-- End Search Box -->
<?php
/*if($this->keyword !== false){
?><h3><?php echo vmText::sprintf('COM_VM_SEARCH_KEYWORD_FOR', $this->keyword); ?></h3><?php
}*/
$j = 'jQuery(document).ready(function() {
jQuery(".changeSendForm")
.off("change",Virtuemart.sendCurrForm)
.on("change",Virtuemart.sendCurrForm);
})';
vmJsApi::addJScript('sendFormChange',$j);
} ?>
<?php // Show child categories
if(!empty($this->orderByList)) { ?>
<div class="orderby-displaynumber">
<div class="floatleft vm-order-list">
<?php echo $this->orderByList['orderby']; ?>
<?php echo $this->orderByList['manufacturer']; ?>
</div>
<div class="vm-pagination vm-pagination-top">
<?php echo $this->vmPagination->getPagesLinks (); ?>
<span class="vm-page-counter"><?php echo $this->vmPagination->getPagesCounter (); ?></span>
</div>
<div class="floatright display-number"><?php echo $this->vmPagination->getResultsCounter ();?><br/><?php echo $this->vmPagination->getLimitBox ($this->category->limit_list_step); ?></div>
<div class="clear"></div>
</div> <!-- end of orderby-displaynumber -->
<?php } ?>
<?php if (!empty($this->category->category_name)) { ?>
<h1><?php echo vmText::_($this->category->category_name); ?></h1>
<?php } ?>
<?php
if (!empty($this->products)) {
//revert of the fallback in the view.html.php, will be removed vm3.2
if($this->fallback){
$p = $this->products;
$this->products = array();
$this->products[0] = $p;
vmdebug('Refallback');
}
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
if(!empty($this->orderByList)) { ?>
<div class="vm-pagination vm-pagination-bottom"><?php echo $this->vmPagination->getPagesLinks (); ?><span class="vm-page-counter"><?php echo $this->vmPagination->getPagesCounter (); ?></span></div>
<?php }
} elseif ($this->keyword !== false) {
echo vmText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
}
?>
</div>
<?php } ?>
</div>
<?php
if(VmConfig::get ('ajax_category', false)){
$j = "Virtuemart.container = jQuery('.category-view');
Virtuemart.containerSelector = '.category-view';";
vmJsApi::addJScript('ajax_category',$j);
vmJsApi::jDynUpdate();
}
?>
<!-- end browse-view -->
I expected to be able to avoid the creation of those links, but I can't find how. My knowledge of PHP is near zero, I only know it's executed on the server and the results are pieces of html in the file.
I couldn't find the <h2>, or the <img> tags and I don't know how to thouch these things. My guess is the piece of code that I need to change is between lines 165 and 177. But I don't know what I have to do.
I would be happy if I could direct those links to an specific page,
Thank you.
See http://forum.virtuemart.net/index.php?topic=128401
also check in the sublayouts/product.php
over ride this .. this is where the individual product "tiles" are created on the cat pages
/html/com_virtuemart/sublayouts/product.php
Always mention versions first!
Sorry for the confusion:
Version of Joomla 3.9.1
Version of Virtuemart 3.4.2
Through the template overides tool, inside com_virtuemart I don't have the sublayouts folder :/ only:
Quoteaskquestion
cart
category
invoice
manufacturer
orders
productdetails
recommend
user
vendor
virtuemart
vmplg
And none of it has a product.php file
I do have it in root/html/components/com_virtuemart
This is the content of that file:
<?php
/**
* sublayout products
*
* @package VirtueMart
* @author Max Milbers
* @link https://virtuemart.net
* @copyright Copyright (c) 2014 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL2, see LICENSE.php
* @version $Id: cart.php 7682 2014-02-26 17:07:20Z Milbo $
*/
defined('_JEXEC') or die('Restricted access');
$products_per_row = empty($viewData['products_per_row'])? 1:$viewData['products_per_row'] ;
$currency = $viewData['currency'];
$showRating = $viewData['showRating'];
$verticalseparator = " vertical-separator";
echo shopFunctionsF::renderVmSubLayout('askrecomjs');
$ItemidStr = '';
$Itemid = shopFunctionsF::getLastVisitedItemId();
if(!empty($Itemid)){
$ItemidStr = '&Itemid='.$Itemid;
}
$dynamic = false;
if (vRequest::getInt('dynamic',false) and vRequest::getInt('virtuemart_product_id',false)) {
$dynamic = true;
}
foreach ($viewData['products'] as $type => $products ) {
$col = 1;
$nb = 1;
$row = 1;
if($dynamic){
$rowsHeight[$row]['product_s_desc'] = 1;
$rowsHeight[$row]['price'] = 1;
$rowsHeight[$row]['customfields'] = 1;
$col = 2;
$nb = 2;
} else {
$rowsHeight = shopFunctionsF::calculateProductRowsHeights($products,$currency,$products_per_row);
if( (!empty($type) and count($products)>0) or (count($viewData['products'])>1 and count($products)>0)){
$productTitle = vmText::_('COM_VIRTUEMART_'.strtoupper($type).'_PRODUCT'); ?>
<div class="<?php echo $type ?>-view">
<h4><?php echo $productTitle ?></h4>
<?php // Start the Output
}
}
// Calculating Products Per Row
$cellwidth = ' width'.floor ( 100 / $products_per_row );
$BrowseTotalProducts = count($products);
foreach ( $products as $product ) {
if(!is_object($product) or empty($product->link)) {
vmdebug('$product is not object or link empty',$product);
continue;
}
// Show the horizontal seperator
if ($col == 1 && $nb > $products_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
// this is an indicator wether a row needs to be opened or not
if ($col == 1) { ?>
<div class="row">
<?php }
// Show the vertical seperator
if ($nb == $products_per_row or $nb % $products_per_row == 0) {
$show_vertical_separator = ' ';
} else {
$show_vertical_separator = $verticalseparator;
}
// Show Products ?>
<div class="product vm-col<?php echo ' vm-col-' . $products_per_row . $show_vertical_separator ?>">
<div class="spacer product-container" data-vm="product-container">
<div class="vm-product-media-container">
<a title="<?php echo $product->product_name ?>" href="<?php echo JRoute::_($product->link.$ItemidStr); ?>">
<?php
echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
?>
</a>
</div>
<div class="vm-product-rating-container">
<?php echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$showRating, 'product'=>$product));
if ( VmConfig::get ('display_stock', 1)) { ?>
<span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"></span>
<?php }
echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$product));
?>
</div>
<div class="vm-product-descr-container-<?php echo $rowsHeight[$row]['product_s_desc'] ?>">
<h2><?php echo JHtml::link ($product->link.$ItemidStr, $product->product_name); ?></h2>
<?php if(!empty($rowsHeight[$row]['product_s_desc'])){
?>
<p class="product_s_desc">
<?php // Product Short Description
if (!empty($product->product_s_desc)) {
echo shopFunctionsF::limitStringByWord ($product->product_s_desc, 60, ' ...') ?>
<?php } ?>
</p>
<?php } ?>
</div>
<?php //echo $rowsHeight[$row]['price'] ?>
<div class="vm3pr-<?php echo $rowsHeight[$row]['price'] ?>"> <?php
echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$product,'currency'=>$currency)); ?>
<div class="clear"></div>
</div>
<?php //echo $rowsHeight[$row]['customs'] ?>
<div class="vm3pr-<?php echo $rowsHeight[$row]['customfields'] ?>"> <?php
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'rowHeights'=>$rowsHeight[$row], 'position' => array('ontop', 'addtocart'))); ?>
</div>
<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>
<?php if($dynamic){
echo vmJsApi::writeJS();
} ?>
</div>
</div>
<?php
$nb ++;
// Do we need to close the current row now?
if ($col == $products_per_row || $nb>$BrowseTotalProducts) { ?>
<div class="clear"></div>
</div>
<?php
$col = 1;
$row++;
} else {
$col ++;
}
}
if( (!empty($type) and count($products)>0) or (count($viewData['products'])>1 and count($products)>0) ){
// Do we need a final closing row tag?
//if ($col != 1) {
?>
<div class="clear"></div>
</div>
<?php
// }
}
}
/*if(vRequest::getInt('dynamic')){
echo vmJsApi::writeJS();
}*/ ?>
The only
<h2> tag I find (line 107) is inside a
<div class="vm-product-descr-container">, which does not correspond to
<div class="width70 floatright">,
<div class="product floatleft width 50 vertical-separator"> or
<div class="row">. Which are the divs the link I want to remove is nested in my page ( https://www.sherpaexpert.com/index.php/selector-de-escaleras? )
The
<img> is nowhere to be found.
Also, is to my understanding, that if you don't proceed through a template override, when I update virtuemart, the changes will revert.
How should I proceed? what I have to change? Is this file at all what I need to change?
Thank you.
This is actually a Joomla question. This applies to ALL exetnsions to Joomla.
You can find guidance here:
https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Jörgen @ Kreativ Fotografi
you have to create the folder sublayouts if it isn't there and copy in the original sublyouts/products.php!! That's how over rides work!
OK the file to edit and override is components/com_virtuemart/sublayouts/products.php
The edits are relatively simple, you were looking for h2 & img when it is easier to look for the link <a or the div classes. All you have to do then is remove the link code and create the override.
Find
<div class="vm-product-media-container">
<a title="<?php echo $product->product_name ?>" href="<?php echo JRoute::_($product->link.$ItemidStr); ?>">
<?php
echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
?>
</a>
</div>
Replace with
<div class="vm-product-media-container">
<?php
echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
?>
</div>
and
Find
<h2><?php echo JHtml::link ($product->link.$ItemidStr, $product->product_name); ?></h2>
Replace with
<h2><?php echo $product->product_name; ?></h2>
Put the edited file as an override in templates/YourJoomlaTemplate/html/com_virtuemart/sublayouts/ - you will have to create the sublayouts directory if it does not already exist.
Thank you all! it's solved.
Happy holidays.