I need to get some node via ajax, but when trying to access node through custom hook_menu callback I got 404 (RH setting: page not found).
Let's say I have hook_menu item:
$items['ajax/%node/%ctools_js'] = array(
'title' => 'Node title',
'title arguments' => array(1),
'page callback' => 'custom_page_callback',
'page arguments' => array(1, 2),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
In my custom_page_callback I'm using node_view(%node_path_argument) and ajax commands to render and display content.
'access callback' => TRUE allows me to see even unpublished content but not content hidden (i.e. page not found) by RH module.
Is this normal behavior? I thought that RH module blocks access only when visiting node/x path.
Comments
Comment #2
olofbokedal commentedThat is not the intended behavior, so it's definitely a bug.
Probably some logic within the implementation of hook_node_view().
Comment #3
hgoto commentedI believe, in order to fix this, it's better to implement
hook_menu_alter()and a custom page callback which wraps the original callback. Because adjustingrh_node_node_view()so that the alteration would be applied only to the default page/node/%nodeis a little tricky.This is the same approach as in the patch #2711941-1: Add support for Taxonomy Term feeds. I tried making a patch for this.
Comment #4
olofbokedal commentedThere's perhaps a more suitable issue for the patch above. I won't close this issue though, better to keep things open until solved in some way.
Comment #5
hgoto commented@olofjohansson thank you for your response! I see. I'll try to contribute in the issue #2486101: Trigger RH regardless of page callback later.
Comment #6
rob230 commentedThis is a bug in the Drupal 8 version of the module as well.
If I set a particular content type to 404, then my own custom route like this also 404s:
This route (and any route using the node object of this type) will 404 unless rabbit_hole settings for that content type are changed.
The expected behaviour is the rabbit_hole module would only affect the path that displays the node, e.g.
node/{node}.Comment #7
imyaro commentedI don't think that patch in comment #3 is a good decision, because in this case nodes in the listings (in "teaser"-type view modes) will be affected too. It is not the case that Rabbit Hole module has to handle
Comment #8
japerryPage Manager 8.x-1.x is no longer supported, closing.