[FX.php List] Just Curious

John Phillip Barclay jbarclay at uiuc.edu
Thu Jul 20 12:58:10 MDT 2006


I have "top level" smarty templates for all the web pages, emails, and
log entries that the application generates.

I also have smarty templates for all the commonly reused subcomponents
such as menus, footers, etc that are not constant in all "top level"
templates.  

Each .php page has its own "content" smarty template that when evaluated
goes into the "top level" web page template for the application.  For
example the login.php has a login smarty template that has all the login
variations (login, logout, send email reminder etc).

I keep all these in a folder that the nonprogrammers have access to so
they can change wording on directions, menu titles, etc without
bothering me.   Aside from making the code more readable and workable,
this separation of labor is the main use I have for templates.

I have a general function that maps fmp xml to a smarty friendly data
structure that I pass into smarty.  This is because smarty has limited
programming abilities (by design).  I use all the looping and html input
functions a lot.

My pages generally flow as below.  I have a lot of PHP classes that
would make the examples less transparent so this is a simplification.


### generate content section of page ###
CODE that generates data A
$contentSmarty->assign('contentA',$contentAvariable); 
CODE that generates data B
$contentSmarty->assign('contentB',$contentBvariable); 
Evaluate content smarty to get html for body of page.
$pagecontent =
$contentSmarty->fetch($GLOBALS["conf"]["templatespath"].'/thispageconten
ttemplate.tpl' );


## integrate into top level page template ##
Create "top level" web page template ($page)

$page->assign('title','login and logout page')
$page->assign(js, $js)// javascript specific to this page
$page->assign(content, $pagecontent)
$page->assign(menutype, 'A') // use menu type A on this page

$wholepage =
$page->fetch($GLOBALS["conf"]["templatespath"].'/webpage.tpl' );	

		
Print $wholepage;

John Barclay, College of Education, University of Illinois


-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of DC
Sent: Thursday, July 20, 2006 1:21 PM
To: FX.php Discussion List
Subject: Re: [FX.php List] Just Curious

so you're using smarty... would you mind sharing your thoughts on why? i
use smarty and i'd like to hear how another FX.php developer uses it.

thanks!
dan

John Phillip Barclay had written:

> Templating Languages: XSLT -> smarty templates
_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list


More information about the FX.php_List mailing list