0

I am developing one website where I have one content type (News). Now, some of news content type nodes is adult and must to have age confirmation popup (just warning text, accept and decline button).

Any suggestion how to do that?

0

If you have registered users, you might do it with a role. This would have the benefit of not having to show this more than once.

Other than that, (this is just an idea, I haven't tried it), you could write a small module which implements hook_node_access() .

What you could do in this function is:

  1. allow the user to view the node if there's an adult=true GET variable
  2. disallow the user to view the node if there's an adult=false GET variable
  3. redirect the user to your own YES/NO form when there's no adult variable in GET, appending your current path as a destination GET path, which is then used as the action target for the form, which itself uses the GET method and has an options box with the name of adult

I have no idea how easy it actually is to pull this off, but it seems quite reasonable.

Tell me whether you've done it and if it worked well, that'd be interesting.

EDIT: References you should read to accomplish this task, as you mentioned you are totally new to this.

  1. Learn the basics about creating a new D7 module
  2. Learn what hooks are
  3. Learn how to create a new page with a path with the hook_menu() hook
  4. In the callback function for hook_menu() provide the yes/no-form: Learn about the Drupal form API . Maybe get started with this tutorial on forms and complete it with the given API link.
  5. Learn about hook_node_access() here and what to return. In this function, do what I mentioned in the list above and complete your functions.

I hope I could help you in any way, and trust me I know how hard it is to get started.

| improve this answer | |
  • Thanks, I never done anything like that before, I'll try and post results here... – mixerowsky Jul 5 '13 at 12:09
  • Cool, comment if you need help – Victor Purolnik Jul 5 '13 at 16:02
  • Certainly I need help, some example maybe...as I said, I never done anything like that before, all of this is new for me... – mixerowsky Jul 5 '13 at 17:36
  • Okay, I don't know exactly how much help you need, but what I can do is give you references. I'll edit my answer. – Victor Purolnik Jul 6 '13 at 15:37
  • thanks, I appreciate your help...now I start with learning... – mixerowsky Jul 7 '13 at 13:07

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.