|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
kucerar Smarty Rookie
Joined: 05 Apr 2005 Posts: 10
|
Posted: Thu May 19, 2005 6:11 pm Post subject: handling Apache SSIs, simple and complex |
|
|
I may be missing some simple config here, god knows I'm not an expert, let me know...
First way is for simple SSIs, just write a prefilter:
Code: |
function convert_ssi($tpl_source, &$smarty)
{
return preg_replace("/<!--#include virtual=\"(.*)\"-->/U","{{fetch file=\"http://".$_SERVER['HTTP_HOST']."$1\"}}",$tpl_source);
}
//$smarty->register_prefilter("convert_ssi");
|
Second way is for more complex situation, for example having to integrate with a complicated 3rd party manu system that depends on the SSI mechanism on Apache being exercised on the page in context in order to work properly. (MENU SYSTEM, ROLLOVERS, ETC ARE DEPENDENT ON SSI OPERATING ON THE FULL PAGE, HAVE TO GET THE PAGE THROUGH THE SERVER TO MAKE IT OPERATE ON THE PAGE FIRST TO GET RID OF ALL THE SSIs, THEN DO SMARTY TEMPLATING ON THAT PAGE RETURNED FROM SERVER, sorry for yelling...)
In that case define an http template source handler:
Code: |
function smart_http_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
{
$tpl_source = file_get_contents("http://".$_SERVER['HTTP_HOST'].$tpl_name);
return true;
}
function smart_http_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
{
$tpl_timestamp = time();
return true;
}
function smart_http_get_secure($tpl_name, &$smarty_obj)
{
return true;
}
function smart_http_get_trusted($tpl_name, &$smarty_obj)
{
}
$smarty->register_resource("smart_http", array("smart_http_get_template",
"smart_http_get_timestamp",
"smart_http_get_secure",
"smart_http_get_trusted"));
...
$smarty->display("smart_http:/bulletin/renew/subscribe.html");
|
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|