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

How to make if statements effect template

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


Joined: 15 Mar 2016
Posts: 1

PostPosted: Tue Mar 15, 2016 5:56 pm    Post subject: How to make if statements effect template Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Mar 15, 2016 6:58 pm    Post subject: Reply with quote

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
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 -> 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