ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

What is the difference between Template Access and manually restricting access with a global conditional?

March 23, 2012 12:37pm

Subscribe [1]
  • #1 / Mar 23, 2012 12:37pm

    liberty79

    135 posts

    I’m trying to set up a preview template for channel entries that only members of certain groups can see.

    I can do it* with a global conditional as outlined in the FAQs here:

    http://ellislab.com/forums/viewthread/130553/

    But what purpose does the Access/“Can view this page” radio buttons serve? Is it a different way to achieve the same result? I was thinking so, but my fiddling around with this is leaving me scratching my head. Trying to get a grasp on these concepts.

    I’m logged in as a Super Admin. If I set all the Access radio buttons to YES, I can see the template. The only radio button that seems to affect whether or not I can see the template is GUEST. If I set GUEST to NO, I can no longer see the template (again, logged in as Super Admin).

    * The method in that article only seems to work within the body of the HTML document for me. Can I not make the first line:

    {if member_group == 1}

    and the very last line

    {/if}

    if I want to restrict access to the entire template?

    Current version running is 2.3.1

  • #2 / Mar 23, 2012 1:36pm

    liberty79

    135 posts

    trying to figure out what’s going on, I ran a little test to make sure I am logged in:

    {if logged_out} You are logged out. {/if}
    {if logged_in} You are logged in.{/if}

    It keeps returning that I’m logged out. If I go to my admin page, log in and click VIEW template, am I not logged in?

  • #3 / Mar 25, 2012 9:14am

    Sean C. Smith

    3818 posts

    Hi liberty79,

    I’m sorry that you are having trouble with this. If you are logged in to the CP you should also be logged in to to the front end of the site, provided you are using the same browser. If that is true, then you should be seeing you are logged in based on the code in the second post.

    I have used the radio restricting template access to redirect unauthorized visitors to a login page by turning off access to guests or member groups that do not have the correct permission levels. So to answer your question in the first post if you are trying to restrict the whole template it would be best to turn off access to that template via the radio buttons. You can also use the drop down to redirect unauthorized visitors to an alternate template.

    Does this help?

    Sean

  • #4 / Mar 26, 2012 8:45am

    liberty79

    135 posts

    thanks Sean, it does help, except I can’t seem to ever be considered logged in. I’m trying three different browsers. Any ideas?

  • #5 / Mar 27, 2012 7:06pm

    Sean C. Smith

    3818 posts

    Hi liberty79,

    Could you try adding the following to your config.php file and let me know if this clears things up for you?

    $config['admin_session_type'] = "c";
    $config['user_session_type'] = "c";

    Sean

  • #6 / Mar 28, 2012 1:26pm

    liberty79

    135 posts

    Hi liberty79,

    Could you try adding the following to your config.php file and let me know if this clears things up for you?

    $config['admin_session_type'] = "c";
    $config['user_session_type'] = "c";

    Sean

    I"ve added that as the last two lines of System>expression engine/config/config.php

    Same result, unfortunately

  • #7 / Apr 02, 2012 5:06pm

    Dan Decker

    7338 posts

    Hi liberty79,

    I’ll address your original question first. The difference would be, setting those restrictions presents an HTTP Auth to the browser when you try to visit a restricted template. The use in that would be setting a Group with a Member Account that you could distribute to a group of people. With that, the member wouldn’t have to login to a particular form on the site fist.

    Now, on to the login/loggout issue. When you experience this, are you using the same browser to login to the control panel and visit the template? Does this only happen when you use the View template link? What if you visit the URL in another tab with the same browser, does it show you logged in?

    I look forward to your reply.

    Cheers,

  • #8 / Apr 02, 2012 7:05pm

    liberty79

    135 posts

    Hi liberty79,

    I’ll address your original question first. The difference would be, setting those restrictions presents an HTTP Auth to the browser when you try to visit a restricted template. The use in that would be setting a Group with a Member Account that you could distribute to a group of people. With that, the member wouldn’t have to login to a particular form on the site fist.

    Got it. Thanks

    Now, on to the login/loggout issue. When you experience this, are you using the same browser to login to the control panel and visit the template?

    Yes

    Does this only happen when you use the View template link?

    I can’t get the above code to tell me “You are logged in” in any instance. If I login to the admin page, go to template manager and click VIEW template, it’s telling my I am logged out.

    What if you visit the URL in another tab with the same browser, does it show you logged in?

    it does not

  • #9 / Apr 05, 2012 4:13pm

    Dan Decker

    7338 posts

    Hi liberty79,

    This is odd, indeed.

    Ok, let’s try a few things.

    Is this on a live server? Do you have a domain assigned to it?

    In Admin->Security and Privacy->Security and Sessions, make sure the Control Panel is set to Cookies and Sessions and that the User is set to cookies only. In order for these to stick, you’ll need to take out the $config variables Sean suggested.

    Do you have any $config variables set that have to do with cookies? What do you have set in Admin->Security and Privacy->Cookie Settings?

    I look forward to your reply!

    Cheers,

  • #10 / Apr 05, 2012 4:19pm

    liberty79

    135 posts

    Is this on a live server? Do you have a domain assigned to it?

    Hey Dan, yes, this is on a live server. There are no membership functions required at the moment, but I’m working on something that will need to recognize whether or not a user is logged in.

    In Admin->Security and Privacy->Security and Sessions, make sure the Control Panel is set to Cookies and Sessions and that the User is set to cookies only. In order for these to stick, you’ll need to take out the $config variables Sean suggested.

    I just checked and that is how it’s setup right now.

    Do you have any $config variables set that have to do with cookies?

    Other than Twitter timeline and removing index.php from URL’s, I’m on a pretty out-of-the-box installation.

    What do you have set in Admin->Security and Privacy->Cookie Settings?


    Cookie Domain, Cookie Path, Cookie Prefix fields are all empty.

  • #11 / Apr 09, 2012 1:20pm

    Dan Decker

    7338 posts

    Hi liberty79,

    I think we might need a closer look at this. Be looking for an email from us!

    Cheers,

  • #12 / Apr 09, 2012 1:37pm

    liberty79

    135 posts

    replied. thanks

  • #13 / Apr 10, 2012 12:09pm

    Dan Decker

    7338 posts

    Hey all,

    Just letting the Community know that we are working with liberty79 privately on a resolution and will report back here when have that.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases