Hello/Hi/Greetings,
I'm trying to add date php to a .tpl file.
I understand I can add
$smarty->assign('currentDate', $date("Y-m-d")); to a php file.
and then
<h1>{$currentDate}</h1>
to the .tpl file.
Which php file should I add the $smarty tag to?
Many thanks.
(Copy here your environment details, found on your Piwigo page [Administration > Tools > Maintenance])
Piwigo URL: http://
Offline
Hi :-)
Where ?
photo page ? header? footer ?
Offline
Hi,
It's the footer.tpl on the Bootstrap Darkroom theme.
Line 15 - I would like to insert a © php current year tag, so it's
{'Powered by'|@translate} <a href="{$PHPWG_URL}" class="Piwigo">Piwigo</a> | ©{php current year tag} AH Photos
Thanks.
Offline
Personal plugin
add_event_handler('loc_end_page_tail', 'datefooter');
function datefooter(){
global $template;
$template->assign('currentDate', date("Y-m-d"));
$template->append('footer_elements', '<h1>{$currentDate}</h1>');
}
}
Offline
Hi,
I made this plugin and loaded into the plugins folder.
<?php
/*
Plugin Name: Date Code
Version: 1.0
*/
add_event_handler('loc_end_page_tail', 'datefooter');
function datefooter()
{
$template->assign('currentDate', $date("Y-m-d"));
$template->append('footer_elements', '<h1>{$currentDate}</h1>');
}
?>
I had to remove the last brace from the code you sent but I now get this error,
"Notice: Undefined variable: template in /home/ahimage/public_html/pm/plugins/Datetag/main.inc.php on line 10"
To see the full error message go to: https://www.ahimages.co.uk/pm/
Thanks
AH
Offline
Hi :-)
create file footerdate.tpl in personal plugin
<h1>{$currentDate}</h1>
and in main.inc.php
define('Pdate_DIR' , basename(dirname(__FILE__))); define('Pdate_PATH' , PHPWG_PLUGINS_PATH . Pdate_DIR . '/'); add_event_handler('loc_end_page_tail', 'datefooter'); function datefooter() { global $template; $template->assign('currentDate', date("Y-m-d")); $template->set_filename('footerdate', realpath(Pdate_PATH.'footerdate.tpl')); $template->append('footer_elements', $template->parse('footerdate', true)); }
Offline
That's working. Many thanks for the help. :)
Offline