If you view a node using a view_mode_page menu_get_object() will return NULL.
This can cause issues integrating with other modules, and also means the correct node-type-CONTENT-TYPE-CLASS isn't added to the body tag.
If you view a node using a view_mode_page menu_get_object() will return NULL.
This can cause issues integrating with other modules, and also means the correct node-type-CONTENT-TYPE-CLASS isn't added to the body tag.
Comments
Comment #2
leon kessler commentedMy quick fix is to not use view_mode_page, and instead add the pages yourself using a
hook_menu_alter().E.g.
I believe the
%nodeauto-load argument is what achieves the router object being available.I haven't had enough time to dig around with the code in this module, but I'd imagine it would be possible to fix this (as it also uses
hook_menu_alter()).Note that the above code will add your page to all content types.
Comment #3
leon kessler commentedAh the answer was right there!
To ensure
menu_get_object()can load the node, set the URL Pattern for your view mode page to use the%nodeargument.E.g.
node/%node/new-page