show login form in the popup or lightbox

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36092
Joined: Sat Apr 05, 2008 9:58 pm

Re: show login form in the popup or lightbox

Post by Webdongle » Sat Mar 05, 2011 6:58 pm

Yes, Create it in an Article view code <> Then paste into the url of the menu item.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

User avatar
gilles007
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Fri Jun 15, 2007 4:58 pm

Re: show login form in the popup or lightbox

Post by gilles007 » Tue Mar 08, 2011 12:30 pm

hey guys, still trying to use the "modal" version of the solution. Still no go.

Do I put the php line in my template's index.php?

PS. the class="modal" syntax generates an error, so it's still unclear as to the correct syntax for the url to make the login component modal.

any ideas?
G

User avatar
quazi_ahasan
Joomla! Apprentice
Joomla! Apprentice
Posts: 43
Joined: Fri Mar 11, 2011 2:48 pm

Re: show login form in the popup or lightbox

Post by quazi_ahasan » Fri Mar 11, 2011 2:57 pm

hi, I tried and followed your way but how can I control the forms hight & width, I appreciate your help.... :)
gilles007 wrote:Hi Webdongle,

I put this in as an external URL link:

Code: Select all

http://www.mysite.com/index.php?option=com_user&view=login&tmpl=component" rel="width[400];height[500];" class="jcepopup 
I hope that makes sense.
G

User avatar
gilles007
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Fri Jun 15, 2007 4:58 pm

Re: show login form in the popup or lightbox

Post by gilles007 » Fri Mar 11, 2011 3:11 pm

did you try using the width/height as shown in the example?

by the way, I trashed this whole idea as it wasn't working properly for me and ended up using YOOlogin in a module position instead.
G

User avatar
quazi_ahasan
Joomla! Apprentice
Joomla! Apprentice
Posts: 43
Joined: Fri Mar 11, 2011 2:48 pm

Re: show login form in the popup or lightbox

Post by quazi_ahasan » Sat Mar 12, 2011 7:23 am

Hi G, thanks for replying and for me to it seems not a good idea. because it does not pop-up, opens a new window, which can be done by any menuitem. what about your new idea, is it working well?

By the way I tryed the Hight and width measurement. Didn't worked.
SEO compatible Joomla design in Bangladesh
Beezness Webs
http://www.beeznesswebs.com

User avatar
gilles007
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Fri Jun 15, 2007 4:58 pm

Re: show login form in the popup or lightbox

Post by gilles007 » Sat Mar 12, 2011 1:15 pm

yes quazi,

the yootools solution worked perfectly. I used the slim setting of the extension and positioned it near the bottom of the site. This way it's unobtrusive. Not a popup but does the job.

give it a try.
G

bigsky
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Apr 21, 2009 10:33 pm

Re: show login form in the popup or lightbox

Post by bigsky » Mon May 23, 2011 8:09 am

MeeDNite wrote:Hi,
Use This:

Code: Select all

<?php JHTML::_('behavior.modal'); ?>
<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">login</a>
Thanks Milad. This works almost flawlessly, much appreciated. I have one question. I placed the above code in the Footer of my site and it pops up the modal window as expected and I can login.

Do you or anyone else know how to code this so that when I successfully login, I have write code to dynamically change the "Login" text to "Logout" so that if I click on Logout it calls that function.

Right now, with the code you've given, I have only two ways of logging out. 1>Session expires or, 2>I have to place the login module somewhere, which is what we don't want. Defeats the purpose of what were trying to do.

I've been researching this and trying many things but I'm not knowledgeable in PHP. Any help is appreciated. Been researching MVC Framework and php coding but there's tons to learn. ;p
Not knowing what I'm doing I thought something like this, but I'm clueless. It's the idea that counts right now. I think maybe the book I have uses oldstyle Joomla coding techniques as well. Any ideas anyone?? The below code doesn't work but it's what looks like should work. Heh..

Code: Select all

	<?php JHTML::_('behavior.modal'); ?>
		<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">
<?php
 		if ($user->guest) {
 			echo '<a href="index.php?option=com_user&view=login&tmpl=component">Login</a>';
 		} else {
 			$name = $user->get('username'); 
 			echo "Logged in as " . $name . ", ";
 			echo '<a href="index.php?option=com_user&view=login&tmpl=component">';
 			echo '	Logout';
 			echo '</a>';
 		}
?>
 		</a>
The following code atleast works but only 3/4 or the way IMO. The above code breaks the page. The code below atleast pops up the modal window and I login, but the link isn't changing.

Code: Select all

<?php JHTML::_('behavior.modal'); ?>
<a class="modal" style="color:#FFFFFF;" href="index.php?option=com_user&view=login&tmpl=component">
<?php echo ($user->guest) ? "Login" : "Logout" ?>
</a>
So the link always says "Logout" no matter what. But if I click on the logout link the Modal window will open where the "Logout" button is and I can logout. I'm assuming since I don't know much this is probably fairly insecure.. My uname and passwords are strong, it's the code that's bunk.. my code.. heh

Thanks,
Bigsky

User avatar
verticalgrain
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Mon Dec 01, 2008 4:16 am
Contact:

Re: show login form in the popup or lightbox

Post by verticalgrain » Wed Jun 15, 2011 5:28 pm

I think this module (YJ Pop Login) would serve for this purpose as well and is very easy to use since you just have to install and enable it:

http://extensions.joomla.org/extensions ... ation/8646

User avatar
kurchania
Joomla! Hero
Joomla! Hero
Posts: 2070
Joined: Mon Sep 21, 2009 6:56 am
Location: indore,india
Contact:

Re: show login form in the popup or lightbox

Post by kurchania » Wed Jun 15, 2011 6:29 pm

@verticalgrain
YJ popup login is good but it conflict with jquery of you have any plugin
abhijeet kurchania
The future depends on what you do today

bigsky
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Apr 21, 2009 10:33 pm

Re: show login form in the popup or lightbox

Post by bigsky » Wed Jun 15, 2011 9:44 pm

@verticalgrain
I appreciate your input and helpful hints. What I dislike doing with Joomla is consistently installing 3rd party plugins to solve problems that appear to be solvable through existing native/built-in code. Basically the less 3 party plugins the better IMO.

I've got the code working above but don't have the PHP know how to get it working correctly. Surely I'm missing something very simple that I don't understand with the php coding or javascript/jquery.

I hope someone can point out how to adust my code above to simply change the link title from login to logout once someone logs in. I'm thinking maybe this might be something I can do with jquery or javascript, but I'm new to those technologies as well. Oh well. I'll get it figured out and post back my findings if I ever get the time to do more research on the issue. I can't be the only one that could benefit from achieving this functionality via native methods without having to resort to yet another 3rd party plugin.

bigsky
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Apr 21, 2009 10:33 pm

Re: show login form in the popup or lightbox

Post by bigsky » Tue Jun 21, 2011 5:31 pm

Here's the fix thanks to some friendly help from one of the PHP guru's on the Rochen Forums where I host.

Code: Select all

<p class="loginbox" style="color:#FFFFFF;text-align:center;">
<?php JHTML::_('behavior.modal');
$user =& JFactory::getUser();
 ?>

<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">
<?php
      if ($user->guest) {
         echo '<a class="modal" style="color:#FFFFFF;"
		 href="index.php?option=com_user&view=login&tmpl=component">Login</a>';
      } else {
         echo '<a class="modal" style="color:#FFFFFF;" href="index.php?option=com_user&view=login&tmpl=component">';
         echo 'Logout';
         echo '</a>';
      }
?>
</a>
</p>
Works for me. Hope that helps others. No need for a 3rd party plugin.

User avatar
gilles007
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Fri Jun 15, 2007 4:58 pm

Re: show login form in the popup or lightbox

Post by gilles007 » Tue Jun 21, 2011 6:39 pm

Thanks for posting/sharing your solution bigsky.

bigsky
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Apr 21, 2009 10:33 pm

Re: show login form in the popup or lightbox

Post by bigsky » Tue Jun 21, 2011 8:39 pm

No problem gilles007. Hope someone can put it to use.

Bigsky

User avatar
kurchania
Joomla! Hero
Joomla! Hero
Posts: 2070
Joined: Mon Sep 21, 2009 6:56 am
Location: indore,india
Contact:

Re: show login form in the popup or lightbox

Post by kurchania » Wed Jun 22, 2011 6:48 pm

@bigsky
thanx for your solution much appreciated
but i guess i already mention this thing before :laugh:
abhijeet kurchania
The future depends on what you do today

bigsky
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Apr 21, 2009 10:33 pm

Re: show login form in the popup or lightbox

Post by bigsky » Wed Jun 22, 2011 8:37 pm

kurchania wrote:@bigsky
thanx for your solution much appreciated
but i guess i already mention this thing before :laugh:
Hi Kurchania,

I understand you offered some help and I'm thankful for that. As well as all the others that spent the time to comment in this thread. That got me started looking in the right direction. And that helped. But it was only half the solution for me.

I don't want to rely on 3 party plugins/modules when we can use the built-in native login code to achieve the same goal. Everywhere I looked for solutions, everyone was given the same answer. Poping open a modal window is half the solution IMO, and using 3rd party solutions to solve this task is silly. That's just my opinion and maybe the original thread opener was satisfied with a half baked solution that is stuffed with unneeded code from some 3rd party.

What My Code Offers and what I was trying to accomplish:
  • Use Joomla native login code with as few lines of code as possible.
  • Calling the Joomla login component via an anchor link, called "Login",(can be any anchor link you want) in the footer of the site that will open in a modal window.
  • Once the user authenticates, the "Login" link dynamically changes to say "Logout".
  • Once the user logs out, the anchor link dynamically changes back to say "Login".
Rationale:
  • We want a way for junior admins to login without dedicating a whole article/page just to login/logout.
  • Calling the login component via a modal window gives us the functionality above.
  • Placing the code in the footer of the templates index.php file, allows access to the login function, regardless of which page you are on.
  • Being that it pop's up in a modal window saves on screen real-estate.
  • Dynamically changing the link text from Login to Logout, when logged in. And from Logout to Login after logging out is a friendly and responsible way to remind our junior admins at a glance if they are still logged in or not. (For my task, once logged in, I was told to make the "Logout" Font Size 24px in red to help them remember to logout. Their company policy, not mine. :D
  • No need to spend ANY time worrying about updating/patching YET another 3rd party Extension. If time is money for you, then guess what? Your saving yourself some money. :P
So if someone is looking for a solution like I was, then it's all there. Ultra lean on code, and very flexible.

The most important part of the code that was missing for me was the need to refresh the USER OBJECT. IE..
$user =& JFactory::getUser();
Without the code above, my anchor links wouldn't dynamically change state as needed.

Code: Select all

<p class="loginbox" style="color:#FFFFFF;text-align:center;">
<?php JHTML::_('behavior.modal');
        $user =& JFactory::getUser();  // Gets and refreshes user object
?>

<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">
<?php
      if ($user->guest) {
         echo '<a class="modal" style="color:#FFFFFF;"
       href="index.php?option=com_user&view=login&tmpl=component">Login</a>';
      } else {
         echo '<a class="modal" style="color:#FFFFFF;" href="index.php?option=com_user&view=login&tmpl=component">';
         echo 'Logout';
         echo '</a>';
      }
?>
</a>
</p>

Thanks Everyone,
Bigsky

User avatar
kurchania
Joomla! Hero
Joomla! Hero
Posts: 2070
Joined: Mon Sep 21, 2009 6:56 am
Location: indore,india
Contact:

Re: show login form in the popup or lightbox

Post by kurchania » Fri Jun 24, 2011 6:13 pm

@bigsky
thanx for your explanation
abhijeet kurchania
The future depends on what you do today

djoshi
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Aug 19, 2011 10:16 am

Re: show login form in the popup or lightbox

Post by djoshi » Fri Sep 16, 2011 9:59 am

<?php JHTML::_('behavior.modal'); ?>
<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">login</a>

This code in not working on my local server. Instead of opening in popup, it is opening like <a href=""> without any effect.

Please help.

bigsky
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Apr 21, 2009 10:33 pm

Re: show login form in the popup or lightbox

Post by bigsky » Sat Nov 26, 2011 6:16 am

djoshi wrote:<?php JHTML::_('behavior.modal'); ?>
<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">login</a>

This code in not working on my local server. Instead of opening in popup, it is opening like <a href=""> without any effect.

Please help.
Hi djoshi,

On my localhost WAMP setup, I cut and pasted your code into the footer div of my templates index.php file and it opens in a modal window like it's supposed to. Not sure why this isn't working for you.

I'm using Joomla 1.5.x. I don't know how this code works in Joomla 1.6 or .7

You didn't specify where you were placing your code. Via an Article or via index.php file. If your placing this code via article manager then some code could be getting stripped by your editor or possibly your template makers code if your using a 3rd party template coded by someone else.

To be honest I really don't know WHY this isn't working for you. I'm just trying to help you get more specific so you can get some better help from someone else.

Good luck. You might even try opening your own thread at the same time. Get double exposure and possibly double the help in this thread and the new one. :D

Benixgo
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Apr 08, 2009 3:28 pm

Re: show login form in the popup or lightbox

Post by Benixgo » Wed Jan 18, 2012 12:35 am

...Hi guys...I have inserted this code in a module position ( <!--?php JHTML::_('behavior.modal'); ?--> <a class="modal" href="login">LOGIN</a> ) ...It's working but when you login, the page load in the light box itself...That's not good at all...

...The light box need's to close and then load the redirect page...How can I do that...?

...Thanks for the help...!

Ben

webcreativeng
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Feb 21, 2012 9:51 am

Re: show login form in the popup or lightbox

Post by webcreativeng » Tue Feb 21, 2012 8:50 pm

Hello, everyone. I just saw this post and like the login form.
But when I used it, I get a "An error has occurred" message.
Please help....
Thanks

rokson
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Wed Feb 16, 2011 12:36 am

Re: show login form in the popup or lightbox

Post by rokson » Sun Jul 15, 2012 11:27 pm

bigsky wrote:Here's the fix thanks to some friendly help from one of the PHP guru's on the Rochen Forums where I host.

Code: Select all

<p class="loginbox" style="color:#FFFFFF;text-align:center;">
<?php JHTML::_('behavior.modal');
$user =& JFactory::getUser();
 ?>

<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">
<?php
      if ($user->guest) {
         echo '<a class="modal" style="color:#FFFFFF;"
		 href="index.php?option=com_user&view=login&tmpl=component">Login</a>';
      } else {
         echo '<a class="modal" style="color:#FFFFFF;" href="index.php?option=com_user&view=login&tmpl=component">';
         echo 'Logout';
         echo '</a>';
      }
?>
</a>
</p>
Works for me. Hope that helps others. No need for a 3rd party plugin.
Is possible to use this code in mod_hellome for Jomsocial login and how? I really need this :(
Please read the Forum rules regarding signatures: http://forum.joomla.org/viewtopic.php?t=65

schweiner
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Sep 04, 2012 5:00 pm

Re: show login form in the popup or lightbox

Post by schweiner » Tue Apr 16, 2013 3:50 pm

Hello, i have a problem.

-------
<?php JHTML::_('behavior.modal'); ?>
<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">login</a>
-------

Why does when a user type key "X" the popup close ?

i have joomla 1.5. Thanks for any help.

schweiner
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Sep 04, 2012 5:00 pm

Re: show login form in the popup or lightbox

Post by schweiner » Tue May 14, 2013 9:24 pm

No one ?
schweiner wrote:Hello, i have a problem.

-------
<?php JHTML::_('behavior.modal'); ?>
<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">login</a>
-------

Why does when a user type key "X" the popup close ?

i have joomla 1.5. Thanks for any help.

schweiner
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Sep 04, 2012 5:00 pm

Re: show login form in the popup or lightbox

Post by schweiner » Tue May 28, 2013 9:06 pm

Ok. look: media/system/js/modal.js and delete - case 'x': - bye.
schweiner wrote:No one ?
schweiner wrote:Hello, i have a problem.

-------
<?php JHTML::_('behavior.modal'); ?>
<a class="modal" href="index.php?option=com_user&view=login&tmpl=component">login</a>
-------

Why does when a user type key "X" the popup close ?

i have joomla 1.5. Thanks for any help.


Locked

Return to “Joomla! 1.5 Coding”