Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Show Modified Date on Product Pages

Show Modified Date on Product Pages

Views: 684

Results 1 to 4 of 4
11 Jul 2013, 1:44 AM
#1
kanine avatar

kanine

New Zenner

Join Date:
Mar 2008
Location:
Victoria AU
Posts:
48
Plugin Contributions:
0

Show Modified Date on Product Pages

How would I go about changing the information shown at the bottom of the product pages to a modified date, rather than the date added.

eg
Currently: This product was added to our catalog on Wednesday 30 January, 2013
Preferred: This product was last updated on Thursday 11 July 2013.

I know the field "products_last_modified" is available in the database, but my php/zencart skills just aren't up to the task of dealing with the null values that are present if the product has never been updated. Otherwise I think I could hack together a solution.

Any help would be greatly appreciated.

11 Jul 2013, 5:45 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show Modified Date on Product Pages

I would fetch both the date-added and last-modified from the db, then check for last-modified being null and substitute date-added in that case, to send to output.

11 Jul 2013, 2:37 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show Modified Date on Product Pages

You could customize the file:
/includes/templates/template_default/templates/tpl_product_info_display.php

and using your templates and overrides, customize the code:

    if ($flag_show_product_info_date_added == 1) {
?>
      <p id="productDateAdded" class="productGeneral centeredContent"><?php echo sprintf(TEXT_DATE_ADDED, zen_date_long($products_date_added)); ?></p>
<?php
    } // $flag_show_product_info_date_added

and change it by adding the code in RED:

    if ($flag_show_product_info_date_added == 1) {
?>
[B]<?
define('TEXT_DATE_MODIFIED', 'This product was last updated on %s');
$chk_date_added = zen_products_lookup((int)$_GET['products_id'], 'products_date_added');
$chk_date_modified = zen_products_lookup((int)$_GET['products_id'], 'products_last_modified');
if ($chk_date_modified <= $chk_date_added) {
?>
[/B]      <p id="productDateAdded" class="productGeneral centeredContent"><?php echo sprintf(TEXT_DATE_ADDED, zen_date_long($products_date_added)); ?></p>
[B]<?php } else { ?>[/B]
[B]      <p id="productDateAdded" class="productGeneral centeredContent"><?php echo sprintf(TEXT_DATE_MODIFIED, zen_date_long($chk_date_modified)); ?></p>
<?php } ?>
[/B]<?php
    } // $flag_show_product_info_date_added

then change your language file, again using your templates and overrides for the DEFINE for TEXT_DATE_ADDED to alter the text on how it reads ...

16 Jul 2013, 4:00 AM
#4
kanine avatar

kanine

New Zenner

Join Date:
Mar 2008
Location:
Victoria AU
Posts:
48
Plugin Contributions:
0

Re: Show Modified Date on Product Pages

Ajeh:

You could customize the file:
/includes/templates/template_default/templates/tpl_product_info_display.php

Thanks for this, I will give it a try. Much appreciated.