Re: Re[3]: [SMARTY] dyamic include file variable
| From: | Rob Ellis | Date: | Thu, 09 Jan 2003 22:11:33 +0000 |
| Subject: | Re: Re[3]: [SMARTY] dyamic include file variable | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7103@lists.php.net to get a copy of this message | ||
On Thu, Jan 09, 2003 at 01:38:01PM -0600, Monte Ohrt wrote:
> We do something kind of similar. Instead of rewrite rules, we have one
> rule in apache, the errordoc handler:
>
> ErrorDocument 404 /error_handler/index.php
>
A similar thing is to set up an Apache 'handler' -- e.g.
# all .html files handled by a smarty script
AddHandler smarty-handler .html
Action smarty-handler /scripts/shandler.php
Then have the handler script look at PATH_INFO for what was
requested. So at the simplest level you could just treat
all html files as smarty templates, e.g., with a handler
like
<?php
require_once 'Smarty.class.php';
$smarty = new Smarty;
$template = $DOCUMENT_ROOT . $PATH_INFO;
$smarty->display($template);
?>
and have a smarty site. :-)
Or do more complex things like handling authentication or
parsing $PATH_INFO with regexes to do tricks similar to
mod_rewrite (to set template/vars based on the requested
path or filename rather than GET vars (to work better
with search engines / create virtual files))...
- Rob
--
Rob Ellis <rob@web.ca>
System Administrator, Web Networks