PHP code in template

Mark

Administrator
Staff member
no PHP code should be included via a plugin, and the output put into a template variable.

Or you can use the includes tag as described in the manual

{include "file.txt"} - Includes an external file; if you want to include PHP code or other dynamic content, use the full URL to the file (starting with http://)
 

Doublezero

New Member
I got everything to work, but I can get it to appear where I want it. I've been trying to get it to show in the "table_wrapper.html" template but it always appears at the very top of the page.

Code:
$today = date('d/m/Y');
 
$start_date="01/02/2013";
$end_date="05/03/2013";
$date_from_user="$today";
 
function geraTimestamp($data)
{
    $partes = explode('/', $data);
    return mktime(0, 0, 0, $partes[1], $partes[0], $partes[2]);
}
 
$startDatedt = geraTimestamp($start_date);
$endDatedt = geraTimestamp($end_date);
$usrDatedt = geraTimestamp($date_from_user);
 
if (($usrDatedt >= $startDatedt) && ($usrDatedt <= $endDatedt))
{
    echo file_get_contents("/home/qwerty/public_html/plugins/Sponsor/taken.html");
}   
else
{
    echo file_get_contents("/home/qwerty/public_html/plugins/Sponsor/empty.html");
}
 

Mark

Administrator
Staff member
echo is not correct. That will display at the top of the page instead of in the template...

$TMPL['taken'] = file_get_contents("/home/qwerty/public_html/plugins/Sponsor/taken.html");

$TMPL['empty'] = file_get_contents("/home/qwerty/public_html/plugins/Sponsor/empty.html");

then you can use {$taken} and {$empty} in your templates
 
Top