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

Tutorial: Login/Logout link via modifier

 
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 -> Plugins
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Mon Feb 27, 2012 9:14 pm    Post subject: Tutorial: Login/Logout link via modifier Reply with quote

Login or Logout links are quite helpful. You can use a very small plugin for the text./link replacement.

You may need to modify this plugin a little to add your own login checker.

File: function.loginlink.php
Code:

<?php
/**
* Login/Logout link
*/
function smarty_function_loginlink($params=array(), &$smarty)
{
   $link = 'login.php';
   $text = 'Login';
   
   # Write your own login checker logic here
   if(isset($_SESSION['logged_on']) && $_SESSION['logged_on']==true)
   {
      $link = 'logout.php';
      $text='Logout';
   }
   
   return "<a href=\"{$link}\">{$text}</a>";
}
?>


If it finds the user has logged in, it will display the logout link.
Otherwise, displays the login link. Simple plugin, but re-usable.
Back to top
View user's profile Send private message Visit poster's website
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 -> Plugins 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