|
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 |
Markus_Whiteus Smarty n00b
Joined: 15 Mar 2016 Posts: 1
|
Posted: Tue Mar 15, 2016 5:56 pm Post subject: How to make if statements effect template |
|
|
I am currently creating a messaging system using smarty for a university project and have little experience with it so hopefully someone here can help.
I want to make certain links appear or disappear from the webpage depending on the result of an if statement in this case have a inbox link appear on index.php when the user is logged in but dissapear when the user is logged out the current way I am doing it is by creating the link in the .tpl
Code: | <li><a href="inbox.php" >{$link2}</a></li> |
and then depending on the result of the log in check
setting $link2 to either Inbox or null,
how ever this method still will leave the link on the page albeit not visable, yet still clickable
does anyone know of a way I can change this? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Mar 15, 2016 6:58 pm Post subject: |
|
|
Separate functional blocks of your design into subtemplates and include them based on conditions passed to the template.
I.e.
[code]{if $user.authenticated}{include 'theme/inserts/inbox.tpl' inline}{/if} |
|
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
|