Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
handling Apache SSIs, simple and complex

 
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
kucerar
Smarty Rookie


Joined: 05 Apr 2005
Posts: 10

PostPosted: Thu May 19, 2005 6:11 pm    Post subject: handling Apache SSIs, simple and complex Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP