News:

Looking for documentation? Take a look on our wiki

Main Menu

How to associate a div class to latest products on categories page layout

Started by gpessoa, May 16, 2013, 19:48:43 PM

Previous topic - Next topic

gpessoa

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
J 4.4.4; VM 4.2.6; PHP 8.3.6

andrew.overlord

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>';
}
}
}
}
?>