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

Query strings and varying includes

 
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
Jaguar
Smarty n00b


Joined: 29 Nov 2007
Posts: 1

PostPosted: Thu Nov 29, 2007 9:05 pm    Post subject: Query strings and varying includes Reply with quote

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}&amp;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
View user's profile Send private message
master_kaos
Smarty Regular


Joined: 02 Aug 2007
Posts: 54

PostPosted: Tue Dec 04, 2007 3:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ancient
Smarty Pro


Joined: 07 Jul 2007
Posts: 196
Location: Omaha, Nebraska, United States of America

PostPosted: Wed Dec 05, 2007 2:31 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
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