Sun 09 Aug |
|
How to make a login link in Joomla 1.5 is asked quite regularly in forums. Here's how to do it and add a bit of interactivity with the user.
The first way is to add a menu item to the login screen. In the Menu Manager select "New" and type "External Link". The url to use is http://www.yoursite.com/index.php?option=com_user&view=login You can also add it directly in your template at a suitable position and style it appropriately - <!--login link--> <div id="loginlink"> <a href="http://www.yoursite.com/index.php?option=com_user&view=login">Login</a> </div> <!--end login link--> If we want to add a bit of user interactivity then we first need to get the users name with a JFactory call and store it in a variable which we place in the php section of the template - $username =& JFactory::getUser(); Then we can use this to greet the user if they are logged in and also provide a logout link. <!--login link--> <div id="loginlink"> <?php if ($username->guest) { echo '<a href="http://www.yoursite.com/index.php?option=com_user&view=login">Login</a>'; } else { $name = $username->get('username'); echo 'Hi ' . $name . ' - <a href="http://www.yoursite.com/index.php?option=com_user&view=logout">Logout</a>'; } ?> </div> <!--end login link--> |
| Last Updated on Friday, 04 September 2009 19:29 Read : 13655 times |





























Also, I needed a little extra - namely a link to the user's data in order for the user to change password and so on. In DNN you click the name and I find this to be a intuitive solution. Here's the complete code snippet for this:
<!--login link-->
<div id="loginlink">
<?php
if ($username->guest) {
echo '<a href="/index.php?option=com_user&view=login">Login</a>';
} else {
$name = $username->get('name');
echo 'Hi <a href="/index.php?option=com_user&view=user&layout=form">' . $name . '</a> - <a href="/index.php?option=com_user&view=login">Logout</a>';
}
?>
</div>
<!--end login link-->
please help.
Thanks!
artxComponentWrapper($document);
$username =& JFactory::getUser();
?>) .
Is that right?
thank you all so much!
Its working fine work nice
Thanks,
Helped me fix a problem! Thank you!
Line fixed....