By stephtek on
I am trying to set up a password protected Drupal site that allows users to only view the home page unless they are logged in. I have searched the forums and haven't found a solution. Is this possible? I am pretty new to Drupal.
Comments
IBM tutorial
This tutorial may not be exactly what you want but should get you started, the bit about "Logging into the extranet". You can surround the login part with home page detail.
http://www-128.ibm.com/developerworks/ibm/library/i-osource10/
BTW, all these IBM tutorials are excellent.
www.scryptik.com - Javascript editor with syntax error checking
www.purpleoar.co.nz/scryptik - Javascript editor with syntax error checking
www.purpleoar.co.nz - Web development, Drupal consultancy
Easy theme hack
Stephtek,
Yes, it is possible. The easy way to accomplish this task is to hack page.tpl.php in your themes// directory. If you want to ensure that any unauthenticated user receives a simple login page, do the following:
In page.tpl.php, add the following code to the top of the file
Create a page-login.tpl.php file in whatever template you wish in your themes// directory. Add the following form to the body of the page
That should do it. You'll, of course, want to tweak the login page to look like something a client would want to login to...
Restrict access to a page in a site unless logged in
Hello J,
Thanks for your code..really, i tried it but i couldn,t get it right.Maybe i didn,t placed the file the way it suppose to be. In page.tpl.php i opened it and added below code ontop of the codes in the file.
global $user;
// if the user is not logged in, the user will have a uid of 0...
if (!$user->uid) {
include 'page-login.tpl.php';
return;
}
later i created a login.tpl.php file on my theme directory and placed this code in it
...
Please Login
print base_path(); user/login" method="post" id="loginform" >user:
pass:
endif;...
i coldn,t get any result...pls i will so much appreciate if you can indicate step by step on how to place this code.
Thanks and regards.
fab
Gee can we find harder ways?
Use one of the Taxonomy Control (or _lite) modules, or even the Menu_By_Role module. No coding needed.
Nancy W.
now running 4 sites on Drupal so far
NancyDru
under access control
Disable "access content" for anonymous users.
Laura
_____ ____ ___ __ _ _
design, snap, blog
_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet
Hmm
Wouldn't that block the front page too?
Nancy W.
now running 4 sites on Drupal so far
NancyDru
=-=
Dropping that code in rather then using a module is less resource intensive. When it can be done in code at the theme level, rather then a module it can be considered a beneift over using a module.
Your login block will still
Your login block will still appear along with the logo and site name.
Laura
_____ ____ ___ __ _ _
design, snap, blog
_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet
That is what I ended up
That is what I ended up doing and just mde the 403 page custom. It worked great!