|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Jaguar Smarty n00b
Joined: 29 Nov 2007 Posts: 1
|
Posted: Thu Nov 29, 2007 9:05 pm Post subject: Query strings and varying includes |
|
|
I'm just starting to use Smarty and I'm getting confused on where to seperate HTML from PHP.
First for URL's and query strings, should I build the URL in the PHP file or in the template?
This seems ok, except for when I add more parts in other links. Then it gets a bit long and confusing.
Code: | <a href="print-record.php?database={$database}&id={$id}"> |
or should I do this? Which is forcing HTML into my PHP file.
Code: | <a href="{$print_link}"> |
I have a similar problem with includes. I want to include either the basic search form or advanced search form at the top of the page depending on how the user accessed the page.
Code: | {if $basic_search}
{include file='basic_search.tpl'}
{else}
{include file='advanced_search.tpl'}
{/if}
|
Or is it better practice to do this? By setting the template in the PHP file.
Code: | {include file=$search_template} |
Thanks. |
|
Back to top |
|
master_kaos Smarty Regular
Joined: 02 Aug 2007 Posts: 54
|
Posted: Tue Dec 04, 2007 3:27 pm Post subject: |
|
|
I always do it the first way, build the query string in the template, but the other solution can be fine to. I think that is more of a personal preference.
Same with your second question.
I rarely every include other templates in a template but if I did I would go with the first option again. |
|
Back to top |
|
Ancient Smarty Pro
Joined: 07 Jul 2007 Posts: 196 Location: Omaha, Nebraska, United States of America
|
Posted: Wed Dec 05, 2007 2:31 am Post subject: |
|
|
Go with the first option, it is what I usually put in my templates.
I do it in forums, and hosting account MySQL DB links etc... _________________ Smarty all the way. |
|
Back to top |
|
|
|
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
|