1

I want my homepage to be like Joomla's administration page, meaning there is only a login form displayed on the page. The hard part is, although it is not hard to make a homepage like this and I can set redirection after login to another page, if a logged in user close their browser tab and reopen the homepage, they will just see the login form which now only displays a "logout" button. I can put a link here for them to get to the other pages, but that is awkward and not a very good behavior. I want it to be just like Joomla's administration page, meaning if you are logged in, when you close and reopen browser tab, you will directly get to the administration panel skipping the login page. How can I do this?

  • You can use system Plugin event onAfterRoute and check if it's login page and redirect the user to desired URL from there – Pratyush Aug 28 '18 at 17:26
  • Hmm just saw this question by you - so I guess this is how you end up with your other recent question here: joomla.stackexchange.com/questions/23367/… – FFrewin Aug 31 '18 at 22:03
0

There is actually no difference in the behavior between the backend and front-end site. The mechanism and the concept is the same. There is a restricted area that requires login. If you gain access you see the content, otherwise you see a login-form. That's the whole idea behind this.

One simple way for the front-end would be to have a template that checks for if the user has the required access (logged-in or whatever), so it will display the content of the page, otherwise it will display (load) a login-form.

For example:

$user = JFactory::getUser();

if ($user->guest) {
    // 
    echo "<p>Welcome. Login to your account or create a new one!</p>";
    // Login/Registration Form - Can load the login module
}
else
{
   // Your privileged stuff goes here 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.