Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Tutorial: Login/Logout link via modifier

 
Post new topic   Reply to topic    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:   
Post new topic   Reply to topic    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