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

Links in templates or php?

 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
ikkitousen
Smarty n00b


Joined: 18 Aug 2004
Posts: 2

PostPosted: Wed Aug 18, 2004 3:53 pm    Post subject: Links in templates or php? Reply with quote

Hello,

I'd like to know which way is better:

1) putting all links in the templates.
2) putting smarty variables in the "href" attributes in the templates and assign these variables with the correct link in the corresponding php code page.

And if you can tell me why one way is better than the other one...
Up to now, i use the second method because while designing i don't want to care about where the links go and which parameters have to be passed by...
but maybe i'm wrong?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Aug 19, 2004 7:11 am    Post subject: Reply with quote

I actually do something in between your 1) and 2) (but I'd prefer 2 too, if i had to choose between them).

I use a function href() in php that is used by a plugin-function {href} in the template.

href($params) takes a hash-array of name-value-pairs that returns the link for that set of params. this way the href() function maps abstract links (like "array('section'=>'news', 'item'=>'article2')" ) to concrete ones (like "index.php?section=news&item=article2" or maybe "news.php?item=article2").

from the php-side i can use href() for header("Location: ...")-redirects and to insert cross-links into my content.

from the template i can use {href} to insert links. like <a href="{href section=news item=article2}">...</a> or {href section=news item=$item_id} in a {foreach}-loop. when my php-structrue changes or the site moves in some way, i don't have to touch a single template, i just have to adjust the href()-function to spit out new kinds of links.

this works pretty well for me.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ikkitousen
Smarty n00b


Joined: 18 Aug 2004
Posts: 2

PostPosted: Thu Aug 19, 2004 11:28 am    Post subject: Reply with quote

Huum, very interesting idea, i will check it out...

Thx.
Back to top
View user's profile Send private message
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 -> Smarty Development 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