|
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 |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Mon Feb 27, 2012 9:14 pm Post subject: Tutorial: Login/Logout link via modifier |
|
|
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 |
|
|
|
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
|