|
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 |
ikkitousen Smarty n00b
Joined: 18 Aug 2004 Posts: 2
|
Posted: Wed Aug 18, 2004 3:53 pm Post subject: Links in templates or php? |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Aug 19, 2004 7:11 am Post subject: |
|
|
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 |
|
ikkitousen Smarty n00b
Joined: 18 Aug 2004 Posts: 2
|
Posted: Thu Aug 19, 2004 11:28 am Post subject: |
|
|
Huum, very interesting idea, i will check it out...
Thx. |
|
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
|