This should be a quick one, hopefully. It will require a bit of programming skill as well as some understanding of how Joomla works behind-the-scenes.
Joomla doesn't come with a built-in module for showing a Login/Logout link. I'm sure that someone in the community has made one, but for verbosity I'll explain how to build your own.
First, let's create a link in our template to send people to our login page.
index.php in template:
<?php
defined('_JEXEC') or die('Restricted access');
...
$user =& JFactory::getUser();
echo '<?xml version="1.0" encoding="utf-8"?'.'>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php echo $this->language; ?>"
lang="<?php echo $this->language; ?>"
dir="<?php echo $this->direction; ?>" >
<head>
...
</head>
<body>
...
<!-- Start of Login Link -->
<div class='loginBox'>
<a href="/component/user/login">Login</a>
</div>
<!-- End of Login Link -->
...
</body>
</html>

...
<!-- Start of Login Link -->
<div class='loginBox'>
<a href="/component/user/login">
<?php echo ($user->guest) ? "Login" : "Logout" ?>
</a>
</div>
<!-- End of Login Link -->
...

Finally, let's add a little spice and show the person who they are logged in as in the same space.
index.php in template:
... <div class='loginBox'>
<a href="/component/user/login">
<?php if ($user->guest) { echo '<a href="/component/user/login">Login</a>'; } else { $name = $user->get('username'); echo "Logged in as " . $name . ", "; echo '<a href="/component/user/login">'; echo ' Logout'; echo '</a>'; }
?>
</a>
</div>
...

And that's it. I hope this was helpful, please let us know if we can improve this article below!


