VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: gpessoa on May 16, 2013, 19:48:43 PM

Title: How to associate a div class to latest products on categories page layout
Post by: gpessoa on May 16, 2013, 19:48:43 PM
Hi there,
How can I associate a <div>New </div> to categories products in order to show a "New" Image on this layout?
The idea is have this "New" image on all new products that are added to the store and automatically turn it off after the latest products time set in Administrator is finished.

Thanks in advanced
Title: Re: How to associate a div class to latest products on categories page layout
Post by: andrew.overlord on May 16, 2013, 22:13:15 PM
Hi.
Try to create a customfield: Custom Field Type = Date, ... Layout position = pos-new.

in your template override:

<?php
if(!empty($product->customfields)) {
foreach($product->customfields as $cfield) {
if ($cfield->layout_pos == 'pos-new') {
$_date explode('-',$cfield->custom_value);
$__date mktime(0,0,0,$_date[1],$_date[2],$_date[0]);
if ( time() < $__date ) {
echo '<div>NEW</div>';
}
}
}
}
?>