0

I have a Joomla site which shows coming soon template if the user goes to the page https://mysite.com

However, I'd like a way to bypass the coming soon page by adding a parameter to the URL. For example, if the site visitor types https://mysite.com?pass then they'll be able to see the original template and not the coming soon page. In my template php file, I've been able to do that using this code

if (isset($_GET['pass'])) {
// show template instead of coming soon page
}

This works in showing the home page, but if I navigate to another page, I still see the coming soon page, so I'd like to pass the variable 'pass' to all the other urls. How can I achieve that?

1 Answer 1

1

Sounds like you just need to drop a variable into the session like this:

$session = JFactory::getSession();
$pass = false;
// if the pass query is ever present, then set pass to true and add it to the session as well
if (isset($_GET['pass'])) {
    $pass = true;
    $session->set('pass', $pass);
} else {
    // no pass query, but check the session to see if this person already has a pass from an earlier request. The second param is the default value.
    $pass = $session->get('pass',false);
}
// now just check $pass for truthiness.

Note also that the orthodox way of doing this is to customise the site offline page and then allow offline access to some users. But you do you.

1
  • Don't use super globals in Joomla
    – Lodder
    Feb 9, 2018 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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