Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Multiple templates in one file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
lsemel
Smarty Rookie


Joined: 18 Aug 2003
Posts: 5

PostPosted: Wed Aug 27, 2003 9:26 pm    Post subject: Multiple templates in one file Reply with quote

My project uses lots of small templates, for different parts and components of the pages. This results an an explosion of template files, and I'd like to make it a bit easier to manage. Is it possible to combine multiple templates in one file?

i.e. something like this. Inside "file.tpl", there would be:

{template name="first"}
... regular smarty template here
{/template}

{template name="second"}
... another template
{/template}

$smarty->display("file.tpl","first");
Back to top
View user's profile Send private message
ptonev
Smarty Rookie


Joined: 21 Apr 2003
Posts: 13
Location: Bulgaria, Sofia

PostPosted: Thu Aug 28, 2003 6:41 am    Post subject: Reply with quote

Yes, it is possible. That I make error f() in my site.

In Error.tpl:
Code:

{capture name=UNKNOWN_ERROR}
  UNKNOWN_ERROR text ot html
{/capture}

{capture name=DB_TXML_NOT_FOUND}
  DB_TXML_NOT_FOUND text ot html
{/capture}

{capture name=TABLE_NOT_FOUND}
  TABLE_NOT_FOUND
{/capture}

{if $smarty.capture.$ERROR_ID ne ""}{else}{assign var="ERROR_ID" value="UNKNOWN_ERROR"}{/if}

<table border="0" cellpadding="0" cellspacing="0" width="760">
   <tr>
.....
{$smarty.capture.$ERROR_ID}</b>
.....
   </tr>
</table>


In Error.php
Code:

$smarty->assign("ERROR_ID", $error_id);

$smarty->display('error.tpl');
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP