gdinari Posted December 1, 2012 Share Posted December 1, 2012 Hi, I wanted to add a date/time stamp in the footer tpl of my theme. I added the desire php code in the override FrontController.php for the footer function, but when I load the page the code comes up empty. Here is my code: override/classes/controllers/FrontController.php class FrontController extends FrontControllerCore { function displayFooter() { // This method will be removed in 1.6 $today = date("F j, Y, g:i a"); self::$smarty->assign( 'date_time', $today ); } } ...then in my footer.tpl I add my new variable: {$today} Cache is not enabled and I dont know what the problem. Can someone please help with this? Thank you Link to comment Share on other sites More sharing options...
gdinari Posted December 2, 2012 Author Share Posted December 2, 2012 Instead of using php I decided that javascript would be easier. So for anyone looking for a solution I used this instead: <SCRIPT language="JavaScript" type="text/javascript"> <!-- // current date - from http://rainbow.arch.scriptmania.com/scripts // Array of day names var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); var monthNames = new Array("January","February","March","April","May","June","July", "August","September","October","November","December"); var dt = new Date(); var y = dt.getYear(); // Y2K compliant if (y < 1000) y +=1900; document.write(dayNames[dt.getDay()] + " " + monthNames[dt.getMonth()] + " " + dt.getDate() + ", " + y); // --> </SCRIPT> 1 Link to comment Share on other sites More sharing options...
singledepo Posted June 17, 2014 Share Posted June 17, 2014 where did you add this script ı tried but its not ok can you help me Link to comment Share on other sites More sharing options...
PascalVG Posted June 18, 2014 Share Posted June 18, 2014 (edited) You could just add this line to the themes/<your theme folder>/footer.tpl: {$smarty.now|date_format:"%A, %B %e, %Y"} Like here: (Sample code from PS 1.5.6.2): <!-- Footer --> <div id="footer" class="grid_9 alpha omega clearfix"> {$HOOK_FOOTER} {if $PS_ALLOW_MOBILE_DEVICE} <p class="center clearBoth"><a href="{$link->getPageLink('index', true)}?mobile_theme_ok">{l s='Browse the mobile site'}</a></p> {/if} {$smarty.now|date_format:"%A, %B %e, %Y"} </div> </div> More info about this here: http://www.smarty.net/docsv2/en/language.modifier.date.format.tpl Hope this helps, pascal. Edited June 18, 2014 by PascalVG link to smarty function documentation added: (see edit history) 2 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