outlet.ee Posted March 21, 2010 Share Posted March 21, 2010 I have the date when I last added new products on my shop's front page. I update it manually every time, could this be updated automatically somehow? Link to comment Share on other sites More sharing options...
rocky Posted March 21, 2010 Share Posted March 21, 2010 I suggest adding the following code in the appropriate PHP file for the TPL you are displaying the date in: $result = Db::getInstance()->executeS('SELECT MAX(`date_add`) FROM `'._DB_PREFIX_.'product`'); $lastProductAddedDate = $result['MAX(`date_add`)']; $smarty->assign('lastProductAddedDate', $lastProductAddedDate); Then you can use {$lastProductAddedDate} in the TPL wherever you want the date displayed. Link to comment Share on other sites More sharing options...
outlet.ee Posted June 28, 2010 Author Share Posted June 28, 2010 Thank you,I am trying to use it on editorial module, which displays some text on homepage, whee in modules/editorial/editorial.php should I insert this code? Also will it work if i put {$lastProductAddedDate} in the text while editing the home text (i.e. not in .tpl)? Link to comment Share on other sites More sharing options...
rocky Posted June 29, 2010 Share Posted June 29, 2010 No, you can't use Smarty code in the text editor on the configuration page. You can only use Smarty code in TPL files. Change the hookHome function in modules/editorial/editorial.php from: function hookHome($params) { if (file_exists('modules/editorial/editorial.xml')) { if ($xml = simplexml_load_file('modules/editorial/editorial.xml')) { global $cookie, $smarty; $smarty->assign(array( 'xml' => $xml, 'homepage_logo' => file_exists('modules/editorial/homepage_logo.jpg'), 'logo_subheading' => 'logo_subheading_'.$cookie->id_lang, 'title' => 'title_'.$cookie->id_lang, 'subheading' => 'subheading_'.$cookie->id_lang, 'paragraph' => 'paragraph_'.$cookie->id_lang, 'this_path' => $this->_path )); return $this->display(__FILE__, 'editorial.tpl'); } } return false; } to: function hookHome($params) { if (file_exists('modules/editorial/editorial.xml')) { if ($xml = simplexml_load_file('modules/editorial/editorial.xml')) { global $cookie, $smarty; $result = Db::getInstance()->executeS('SELECT MAX(`date_add`) FROM `'._DB_PREFIX_.'product`'); $lastProductAddedDate = $result['MAX(`date_add`)']; $smarty->assign(array( 'xml' => $xml, 'homepage_logo' => file_exists('modules/editorial/homepage_logo.jpg'), 'logo_subheading' => 'logo_subheading_'.$cookie->id_lang, 'title' => 'title_'.$cookie->id_lang, 'subheading' => 'subheading_'.$cookie->id_lang, 'paragraph' => 'paragraph_'.$cookie->id_lang, 'this_path' => $this->_path, 'lastProductAddedDate', $lastProductAddedDate )); return $this->display(__FILE__, 'editorial.tpl'); } } return false; } Then you can put {$lastProductAddedDate} wherever you want in editorial.tpl. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now