5

We typically demo new EE sites to clients with the site in "offline" mode, which prevents unauthorized access and requires the client to login before they can see anything. Previously we've either directed clients to the CP to login, or, have left the site online and done the authentication via Apache.

Is it possible to put an EE member login form in the offline template so they can login without having to go to the control panel first?

I've tried inserting this code into my offline template, but, it appears that the EE tags aren't getting parsed when the site's offline:

{exp:member:login_form return="site/index"}
        <p>
                <label>Username</label><br>
                <input type="text" name="username" value="" maxlength="32" size="25">
        </p>
        <p>
                <label>Password</label><br>
                <input type="password" name="password" value="" maxlength="32" size="25">
        </p>
        {if auto_login}
                <p><input type="checkbox" name="auto_login" value="1"> Auto-login on future visits</p>
        {/if}

        <p><input type="checkbox" name="anon" value="1" checked="checked"> Show my name in the online users list</p>
        <p><input type="submit" name="submit" value="Submit"></p>
        <p><a href="{path='member/forgot_password'}">Forgot your password?</a></p>
{/exp:member:login_form}
6

It might be easier for you to leave the site online. You can emulate offline functionality by doing this:

  1. Create an alternate main index template named something like "home."
  2. Create a special "Coming soon" page for your main index template.
  3. Create a snippet with these contents:{if logged_out}{redirect="/"}{/if}
  4. Add the snippet to all of your pages (except the main index template).
  5. Add your login form to the main index ("Coming Soon") page.
  6. (Optional) Link to "/home" instead of "/index" for all of your "Home" links, possibly through the definition of a global variable.

When it comes time to push the site live, you have three things that will have to be done:

  1. Move /home to /index
  2. Empty the contents of the logged_out snippet
  3. (Optional) Change your home links.
  • 1
    I like this approach, although I'd add the redirect logic to the header embed/include/whatever, and redirect to the coming soon page if they're not logged in. Then there's no need to monkey around with different homepages. – Nick Benson Dec 4 '12 at 16:41
  • 1
    That works as well, although you have to be careful to use {if} conditionals that are parsed early. I know how easy it is to want an {if:else} clause to streamline readability in header code, but EE would then parse the {redirect} tag before the conditional. I try to segment some of these more complex bits to help newcomers. – EpicVoyage Dec 4 '12 at 16:51
7

I keep my site in online mode, but have the templates restricted to logged in members. When a non-logged in member visits the site they are redirected to a "splash" template with a login form. Once logged in they can see and do everything.

You can set this up in template preferences - It should be just ejnough to redirect the homepage as no-one else should know other links. If you wanted to you could do the redirect on all templates though.

0

No, you cannot because the offline template is .html and isn't parsed by the EE template engine. Allowing member groups to login when the site is offline is only really available to users who also have CP access.

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.