SUMMARY: how to use display() for dynamic embedded tables
| From: | Joe Rice | Date: | Wed, 07 Nov 2001 13:53:22 +0000 |
| Subject: | SUMMARY: how to use display() for dynamic embedded tables | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1840@lists.php.net to get a copy of this message | ||
Thanks to all that replied. I went with the first response (which
was off the mailing list) I received. It was pointed out
that in my "master" template, home.tpl that i could
do something like this:
{if $my_tpl}{include file=$my_tpl}{else}{include file="default.tpl"}
by setting the file to include as a variable i can, in the calling
php script assign $my_tpl to what ever i want.
include("poll.php");
$t->assign("my_tpl","poll.tpl");
$t->display("home.tpl");
I've taken this a bit further by storing what template name will
be displayed in a db and changing the above to;
include("$php_to_include");
$t->assign("my_tpl",$tpl_to_include);
$t->display("home.tpl");
and supplying the values to $php_to_include and $tpl_to_include
via db query. This requires a little synchronization of script/tpl
names and db entries but, that is why now working on a admin interface.
Thanks to the list and thanks for Smarty.
joe
Joe Rice(riceja@particle6.com)@Tue, Nov 06, 2001 at 10:48:05PM -0600:
> Hello,
> I'm relatively new to Smarty and have one problem
> i can't figure out. I currently have home.php and home.tpl
> working as expected and I'm using php's sessions to maintain state.
> In home.tpl i have a embedded table that holds a very straight forward
> voting/polling feature. I would like to be able to abstract that
> from home.php and home.tpl to poll.php and poll.tpl respectively.
> As you can imagine doing this wasn't any big feat. Independently
> going to poll.php will display just my poll table. With
> the use of require/include i can get the poll back into
> home.php. The problem is how do i get the newly abstracted
> poll.tpl to embed itself back into home.tpl ?
>
> I'm trying to do this in attempt to allow the space in the
> layout where the poll normally sits to be easily changed
> to something other then the poll feature.
>
> I guess i'm thinking kind of like a generic API call in
> home.tpl that will take whatever it gets back and display it.
>
> I've tried {fetch file='http://URL/poll.php'},
> this worked but
> didn't remember or maintain any of the session values. using
> include/require in home.php will maintain the sessions but
> in my approach won't embed the poll table in home.tpl.
>
> Any help would greatly be appreciated.
>
> Thanks,
> joe
>
>
> ---
> You are currently subscribed to smarty as: riceja@particle6.com
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
================= I owe John $1000 =================