1

Let's say I have a parent node with ID equal to 233 that has the following related nodes: 234, 235, 236 (in a relationship field).
Is it possible to restrict access to paths node/234, and node/235, if they are a specific content type, but still show them for the same users in a embedded view inside a local task of ID equal to 233?

7
  • Hello, cmos; welcome on Drupal Answers. By embedded view do you mean a view created with Views?
    – avpaderno
    Commented May 8, 2011 at 5:54
  • Possible duplicate of drupal.stackexchange.com/questions/324/….
    – Berdir
    Commented May 8, 2011 at 7:15
  • @kiamlaluno: yes I am embedding related nodes in the node template by adding something like this: <?php $view = views_get_view('products_features'); print $view->preview('attachment_1', $node->nid); ?>
    – cmos
    Commented May 8, 2011 at 19:08
  • @Bedir : the problem with hook_node_access() is that it removes the possibility of viewing the nodes in the embedded view. Because I can only check for the following operations: 'create','delete', 'update', 'view'. But when I am embedding the view I am actually in the 'view' operation and the nodes I am blocking for 'view' will be blocked in the embedded view aswell.
    – cmos
    Commented May 8, 2011 at 20:12
  • @cmos: You could for example check the path in your hook_node_access() implementation, and deny access if viewed directly on node/x or only allow when viewed through a specific path. Also, please accept your own answer, so that this question is correctly marked as resolved.
    – Berdir
    Commented May 8, 2011 at 23:15

1 Answer 1

2

Looking at the comments I realized that in my case at least the best way of limiting the access for unauthorized users (anonymous mainly) is to not publish the child nodes. And I removed the 'published'='yes' filter in the view itself so I can show those nodes in the parent template. And it works nicely. Thank you for the tips.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.