NYCPHP Meetup

NYPHP.org

[nycphp-talk] Smarty Template question

Cliff Hirsch cliff at pinestream.com
Tue Oct 3 07:45:26 EDT 2006


Rolan:

Many thanks. Seems obviously, but I have been stuck because I use a
single Display command with the "content template" included in the
middle of a master template.

It seems like Multiple Displays would work, but it does make it more
difficult to keep track of lots of pieces in a complex template. Perhaps
I could use Fetch instead to take care of this one problem and then
still use Display to build the composite template.

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Rolan Yang
Sent: Monday, October 02, 2006 10:40 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Smarty Template question

The smarty template does not have to be a complete page. I believe you 
can call a template multiple times from within the PHP document e.g.

$smarty->display('header.tpl');

$data=getTableData($first);
$smarty->assign('data',$data);
$smarty->display('tabletemplate.tpl');

$data=getTableData($second);
$smarty->assign('data',$data);
$smarty->display('tabletemplate.tpl');

$data=getTableData($third);
$smarty->assign('data',$data);
$smarty->display('tabletemplate.tpl');

$smarty->display('footer.tpl');

~Rolan

Cliff Hirsch wrote:
>
> I have a table comprised of a PHP file and Smarty template. It's so 
> lovely that I have decided to display it several times on one page, 
> with different conditions for each iteration. Example: a table for 
> pending projects, a table for completed project.terminated projects,
etc.
>
> If the PHP and templates were built successively, I think this would 
> work. But since, with Smarty, the PHP runs first and than the 
> individual template "pieces" are populated with the assigned 
> variables, the last "table build" would simply be displayed in all the

> tables. Follow me?
>
> Making each PHP version of the table an object would be simple. But 
> how can I use one template for multiple instances on one page? The 
> only solution I can think of it to build an array and have loop over 
> the array for each version of the table. Any other ideas?
>
> Cliff
>
> _______________________________
> *Pinestream Communications, Inc.*
> Publisher of /Semiconductor Times/ & /Telecom Trends/
> 52 Pine Street, Weston, MA 02493 USA
> Tel: 781.647.8800, Fax: 781.647.8825`
> http://www.pinestream.com <http://www.pinestream.com/>
>
>
------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>   
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php




More information about the talk mailing list