0

I have a site where users must log in to access content. For the home page, I'd like these anonymous users to be able to view this content and the login box. Below are the ways I have done this in the past, but I'm looking for comments on how others may do this. Especially for ways that it could be done without touching templates or code.

  • Modify page-front.tpl.php when a user is not logged in. This allows me to remove the "Access denied message"
  • Create a block that is displayed on the home page for anonymous users. However, this still displays the "Access denied message"
  • Implement Taxonomy access and have a term that allows anonymous access. This would eliminate the "Access denied message"

Are there other better methods to do this with as little code as possible? What is the best way?

Thanks.

  • What modules are you already using on your site? Panels? Content Access? Views? I can think of ways to do it with Panels and Content Access, and there might be something possible with Views, too. – Mike Bohlmann Nov 6 '11 at 19:49
0

What kind of permission module are you using ? Is it possible you implement yourself these permission ?

I would restrict node access to anonymous user using a custom module implementing hook_node_access() and allow them to see the nodes on the front page (using the function drupal_is_front_page()):

function MYMODULE_node_access($node, $op, $account) {
  if ($op == 'view' && $account->uid == 0) {
    if (drupal_is_front_page()) {
      return NODE_ACCESS_ALLOW;
    } else {
      return NODE_ACCESS_DENY;
    }
  }
  return NODE_ACCESS_IGNORE;
}
0

You could use frontpage to set different front pages for anonymous, and authenticated visitors.

  • I like the frontpage module, but it looks like it can only be used with Drupal 7. I was looking for something that could be applied to both Drupal 6 and 7. – Tim Koscielski Nov 7 '11 at 14:25

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.