RE: [SMARTY-DEV] Quick Question
| From: | luis | Date: | Wed, 26 Mar 2003 20:27:50 +0000 |
| Subject: | RE: [SMARTY-DEV] Quick Question | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1033@lists.php.net to get a copy of this message | ||
It's an idea but I really don't want to change all the templates and I
can't ensure that everybody involved in the development remembers to use
include preppending the variable.
I did override the fetch and _smarty_include methods and it works. I
would have preferred to override only one function but two is good
enough :-)
Now a theme can override zero, one or many templates just putting the
new templates in templates/$theme_name. That's exactly what I wanted.
BTW: Thanks to Monte, Messju and the people that wrote for this thread.
Luis
-----Original Message-----
From: boots [mailto:jayboots@yahoo.com]
Sent: Wednesday, March 26, 2003 5:22 PM
To: smarty-dev@lists.php.net
Subject: RE: [SMARTY-DEV] Quick Question
luis:
------------------
Well, I can answer myself, no. If I have
display('foo.tpl');
and foo.tpl {includes file='header.tpl'}
I need to look BOTH for foo.tpl and header.tpl in templates/$user
and if they are not found there in templates/ If I redefine fetch then
foo.tpl can be checked but fetch is not called for the included
header.tpl template. Ideas?
------------------
Well, to add just a little bit more to this thread... instead of
overriding smarty's internal functions, you might be able to do the
following.
1) extend Smarty as per Monte's suggestion, overriding the default
smarty->Display. In the new Display code, also add a smarty assign
statement such as:
$this->assign('_tpl_path', $tpl_path);
where $tpl_path is either blank ("") or the user path to the file (ie.
$user.'/' as appropriate)
In your templates, you would include files like this:
{include file=$
_tpl_pathheader.tpl}
This definately works, though, unfortunately, you have to change your
template code slightly. The nice thing, is that this prevents Smarty
from having to search paths on every invocation of a template.
It may not be a bad idea to create a custom function in this case.
Currently, {include} does NOT work the way you want it to and the way
you want it to work DEFINATELY is not in line with the current design.
Therefore, a custom function seems appropriate. Then again, I like the
assign approach :)
just my 2c.
xo boots
__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php