News:

Support the VirtueMart project and become a member

Main Menu

change location of featured items on front page

Started by dsrpmedia, January 09, 2017, 19:13:33 PM

Previous topic - Next topic

dsrpmedia

Hi

I am using the 'featured products' option in the config. - but it is putting the featured products at the bottom of the front page, underneath all the categories

what file do I edit to create an override that would place the featured products BEFORE the categories on the front page?

Thank you!!

Studio 42


dsrpmedia

yes I need to do a template override, but I don`t know which file to edit - which file  controls where the featured items  loads onto the front page?

Studio 42

Main front page is :
JOOMLAROOT\components\com_virtuemart\views\virtuemart\tmpl\default.php

the code to render all products is:
# Show template for : topten,Featured, Latest Products if selected in config BE
if (!empty($this->products) ) {
$products_per_row = VmConfig::get ( 'homepage_products_per_row', 3 ) ;
echo $this->renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$products_per_row,'showRating'=>$this->showRating)); //$this->loadTemplate('products');
}

So to display all before move this code before categories loop.
If you want only featured, you need to extract the featured from list and unset it in PHP.
But this file is Depreciated so in last release you need to use a category view, but the code changes are similar.

aftertaf

Hi,
I'm not using the depreciated Shopfront, but only category mode via menus that target each category I wish to display.
I'm using overrides to the category, products, and product details views.

However, i cannot find the part where the normal prodycts and the feztured products are rendered, despite your code example above.

In the output of my page, i see the following...

<div id="Products" class="products-view">...</div
<div id="Produits en vedette" class="featured-view">...</div>

From what I can tell, with comments added in the HTML part of the php files, the one "renderVmSubLayout" call to 'products' is doing all the work, creating the main DIV for the products, then underneath creating the Featured Products DIV.

I don't see what I can change to make the order inverted..
Would appreciate some help to put the featured products up top...
david


Studio 42

JOOMLAROOT\components\com_virtuemart\views\category\tmpl\default.php
But better override it in your template.
If you only want it in main, create a new file with another name(copy default.php)
eg. JOOMLAROOT\components\com_virtuemart\views\category\tmpl\front.php
and move to top
<?php
if (!empty(
$this->products)) {
$products = array();
$products[0] = $this->products;
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

?>

And use this new layout for your front page only in your Joomla menu item settings

aftertaf

Quote from: Studio 42 on October 26, 2017, 16:36:45 PM
JOOMLAROOT\components\com_virtuemart\views\category\tmpl\default.php
But better override it in your template.
If you only want it in main, create a new file with another name(copy default.php)
eg. JOOMLAROOT\components\com_virtuemart\views\category\tmpl\front.php
and move to top
<?php
if (!empty(
$this->products)) {
$products = array();
$products[0] = $this->products;
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

?>

And use this new layout for your front page only in your Joomla menu item settings

sorry but i don't understand your reply, or maybe you didnt understand my question properly..

I am using multiple overrides already, for category views. All based on the 'JOOMLAROOT\components\com_virtuemart\views\category\tmpl\default.php'
It is onside these files that I cannot see the code that is specifically rendering the Featured Products after the normal list of products : i'm asking for help to find this part.

I see code that looks like what you mention, both at top and at bottom of the default.php file. But i think your example is based on older code also, as the sn,ippets resembling your example are different in the php files i look at.

here is my 'production override' for the category view i'm wanting to modify..
If someone can simply tell me what to move where, as I cannot figure out the logic by myself...

<?php
/**
 *
 * Show the products in a category
 *
 * @package    VirtueMart
 * @subpackage
 * @author RolandD
 * @author Max Milbers
 * @todo add pagination
 * @link http://www.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 9288 2016-09-12 15:20:56Z Milbo $
 */

defined ('_JEXEC') or die('Restricted access');

if(
vRequest::getInt('dynamic')){
if (!empty($this->products)) {
if($this->fallback){
$p $this->products;
$this->products = array();
$this->products[0] = $p;
vmdebug('Refallback');
}
?>
<!-- sOaumetre-php Rendering SubLayout products_soaumetre--><?php
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products_soaumetre'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
?>
<!-- sOaumetre-php Rendering SubLayout products_soaumetre END--><?php
}

return ;
}
?>
<div class="category-view"> <!-- start of soaumetre-php--><?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 (empty(
$this->keyword) and !empty($this->category)) {
// category name below
?>

<h1><?php echo vmText::_($this->category->category_name); ?></h1>
<div class="category_description">
<?php echo $this->category->category_description?>
</div>
<?php
}

// Show child categories
if ($this->showcategory and empty($this->keyword)) {
if (!empty($this->category->haschildren)) {
?>
<!-- sOaumetre-php Rendering SubLayout categories--><?php
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children));
?>
<!-- sOaumetre-php Rendering SubLayout categories END--><?php
}
}

if(
$this->showproducts){
?>

<div class="browse-view">

<?php

if ($this->showsearch or !empty($this->keyword)) {
//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 $this->searchCustomValues ?>
</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(!empty($this->keyword)){
?>
<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 //category name was displayed below by default, moved higher?>



<?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');
}
?>
<!-- sOaumetre-php Rendering SubLayout products--><?php
echo 
shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
?>
<!-- sOaumetre-php Rendering SubLayout products end--><?php
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 (!empty(
$this->keyword)) {
echo vmText::('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ' : (' $this->keyword ')' '');
}
?>

</div>

<?php ?>
</div>

<?php
if(VmConfig::get ('jdynupdate'TRUE)){
$j "Virtuemart.container = jQuery('.category-view');
Virtuemart.containerSelector = '.category-view';"
;

//vmJsApi::addJScript('ajaxContent',$j);
}
?>

<!-- end browse-view -->



Studio 42

All product list including featured are in same value.
If you want only featured, it need to change many code, because sublayout want an array
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
Is the array of all product list including featured.
So you have to remove it from here and add it at begin of your render.
Sorry but i have no lust to do the code. Perhaps someone other have time to write all the code ?

aftertaf

hi,
thanks for the clear reply, makes more sense now.
I didnt want to have featured only, i wanted to put them first, before the main products array on the category view page.
but i'll live without it as I now know it isnt an easy change.
thx again