Jonathan Dart Posted September 11, 2013 Share Posted September 11, 2013 I just tried to remove the guest view page privilege from the homepage template and got the following message: "TEMPLATE 'HOME' IS USED BY THE HOMEPAGE AND THUS MUST HAVE THE 'GUEST' ROLE ASSIGNED." As a work around I thought I'd create a subpage of the homepage called "restricted" or something like that and put all other pages under that. Is there a better way to accomplish this? Link to comment Share on other sites More sharing options...
kongondo Posted September 11, 2013 Share Posted September 11, 2013 (edited) Welcome to the forums Jonathan Dart Without guest role your site is not viewable I believe Maybe if you could explain what exactly you are trying to accomplish? If you don't create any other users, i.e. leave only the defaults (superuser [you] and guest [can only view]), then you have nothing to worry about. Maybe am not getting you Edit: I knew I was not getting you.having read Apeisa's post below...I am kinda slow that way Edited September 12, 2013 by kongondo Link to comment Share on other sites More sharing options...
apeisa Posted September 11, 2013 Share Posted September 11, 2013 I think there are some reason for not being able to restrict guests from home.. maybe PW is just polite for guests? One way to do that kind of check is in template code, and best way there is in prependTemplate (if you use pretty recent version of PW). Just uncomment this line: https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/config.php#L58 and add file called _init.php into your templates folder. Add this snippet there: <?php if ( ! $user->isLoggedIn()) { echo "Sorry dude"; die(); // or redirect to somewhere and check that "not available page" on that if above } 1 Link to comment Share on other sites More sharing options...
teppo Posted September 12, 2013 Share Posted September 12, 2013 Ryan has explained reasoning behind this here (and on couple of other posts, actually, that just came up first.) In addition to what @apeisa suggested above, you could probably use Pete's Maintenance Mode module to achieve what you're asking (not tested, but based on module description it should be doable.) 1 Link to comment Share on other sites More sharing options...
thetuningspoon Posted September 12, 2013 Share Posted September 12, 2013 I rolled my own "maintenance mode" by adding a preferences page with a maintenance_mode checkbox and a RTE field called maintenance_mode_message to display to the user if they're not logged in. I then added the following code snippet to the top of my header include which is included in all my template files: <? if($pages->get('name=preferences')->maintenance_mode && !$user->isLoggedin()) { echo $pages->get('name=preferences')->maintenance_mode_message; exit; } ?> If the conditions are met (user is not logged in and maintenance_mode checkbox is checked), the user will only see the contents of maintenance_mode_message and will not be able to view the site. Link to comment Share on other sites More sharing options...
Jonathan Dart Posted September 13, 2013 Author Share Posted September 13, 2013 Thanks for the feedback guys, this was a can of worms situation. I came to realize I also needed a frontend login form and I leveraged the homepage being viewable by all to accomplish this. I wanted to to have csrf protection in my form so I extended the ProcessLogin core module (https://gist.github.com/jdart/6545755) and called the module in the home template: #home.php echo $modules->get('SpexLogin')->execute(); if (!$user->isLoggedin()) return; Hopefully that will be helpful for someone. Maybe 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now