Easy problem: when users visit a node page on my website, one of the node's integer fields should be changed. Answer: Rules. Now comes the tricky part...

I installed Panels and enabled the node template node_view via the Pages UI. I added the Pane "Node being viewed" content (build mode: Full content), but none of my Rules with an event Content is viewed is triggered anymore on the node pages. After searching around a whole day on the internet, I think my problem is a classic, but I didn't find a clear answer anywhere. Hopefully, we can get over it here once and for all.

Here are some things that I tried so far:

  1. This comment suggested to disable the No extras option in the Pane's settings (which works), but that also renders the comments, comment form, etc.; which is not what I want, since I add those as separate Panes.

  2. Combining the power of Conditional Rules and Rules URL Argument. The general idea is to check on Drupal is initializing whether the path starts with node, save the nid arg(1) as a variable, load the node and make the necessary changes afterwards. Unfortunately, I couldn't find a way to use the nid in the path without using custom PHP (I want to avoid that).

  3. Forgetting about Rules and trying to code is also fine for me, but I haven't found the correct hook yet. Using hook_node_view doesn't work, because it doesn't get called (that's precisely why the Rules aren't triggered). I also tried to use

    function hook_init() {
      if (arg(0) == 'node') {
        $node = node_load(arg(1));

    in my custom module, but that results in some theme related errors, so I'm afraid that my node templates are getting messed up by this. Lastly, different sources referred to hook_ctools_render_alter, so that seemed promising. Though, after some debugging, I quickly gave up trying to understand how this hook works. If this is the correct way to go, I would like to have some more information about the hook or some example code.

Do you have any suggestions to fix this frustrating problem?

Note: I'm using the currently latest versions of all modules, i.e. CTools 1.11, Panels 3.8 and Rules 2.9.

  • 1
    Are you on the latest ctools? .18 or .19 had a change that broke the rule for content is viewed when using panels. My issue post.. drupal.org/node/2556253 Aug 17, 2016 at 0:41
  • Actually, it looks like you'll need to apply that patch because ctools is still on 1.19. I use content I'd viewed on panels fine for lots of things. Aug 17, 2016 at 0:46
  • @NiallMurphy: I applied the patch in your link and it solves the problem, so I reviewed it on drupal.org. Hopefully the CTools maintainers can quickly commit it. I'll keep this question open a little longer and see what happens. Thanks!
    – Jeroen
    Aug 17, 2016 at 9:25
  • The latest ctools 1.10 didn't include this fix fyi. Aug 20, 2016 at 14:24
  • @Niall Murphy: Correct, I have already updated my question accordingly.
    – Jeroen
    Aug 20, 2016 at 20:50

2 Answers 2


You should use Rules Bonus Pack which allows to create a new event when a panel variation is loaded.

Detailed instructions:

  1. Download Rules Bonus Pack and enable "Rules Bonus: Miscellaneous" sub module.
  2. From the panel settings page you will see a new "Reactions" tab. On this tab you will select the new option "Create a Rules event for this variant".
  3. Now open the rule and add a new event. You will find a new section "Rules Bonus: Miscellaneous" with the selected panel variation. Use this event instead the "Content is viewed" one.

It should work as you expect.

Alternative solution

An alternative solution is to write a custom module. You should take a look to the Rules Bonus Pack source code. You can find some inspiration to solve the problem.

Instead using hook_node_view() you can implement hook_ctools_render_alter().

First you should check the handler (node_view) and after load the node data from the ctools/panels context.


function yourcustommodule_ctools_render_alter(&$info, &$page, &$context){
  // Verify if the page/node is the one you want to interact with
  // and set the field value as you wish.

  // First check if the handler is node_view:
  if($context['handler']->task == "node_view"){

    // Then verify the node content from the context sub array
    // The $context variable contains the node data but you
    // have to dig in.
    $node = $context['contexts'][key($context['contexts'])]->data;

    // [... your code ...]


Happy coding :-)

  • Thank you for your answer. I also came across this module during my search, but I really don't want to use any development release on my live website.
    – Jeroen
    Aug 16, 2016 at 18:43
  • Ok, I've edited my original post with an alternative solution.
    – FiNeX
    Aug 16, 2016 at 20:30
  • Hi @Jeroen, I've updated the example code using hook_ctools_render_alter(). With this code you should be able to interact with the node content.
    – FiNeX
    Aug 17, 2016 at 9:52

I think it has got something to do with the node's 'view mode'. Which view mode are you showing the node in, in Panels - Teaser, Default or any custom view mode?

The following steps may help the rule to get triggered when content is viewed in the desired view mode:

  1. Go to Admin > Configuration > Workflow > Rules > edit your rule
  2. Under 'Condition', choose 'Data Comparison' > Compare 'view-mode equals Teaser/Full content/etc.'
  3. Save the rule

I hope you are aware that your rule will get triggered whenever the content is viewed in this view mode anywhere in the site and not just in Panels.

Hope this helps.

Regards, Supriya Rajgopal

  • I have just added to my question that my Pane uses the Full content build mode, but the same issue arises for all building modes. Also, I already have the condition you suggested in my Rule. The problem is that the Rule itself is not triggered, so it doesn't even check the build mode condition. Since the Rule is correctly triggered when a teaser is viewed in a View (which is included in a Panel), it seems to me that the problem should have something to do with Panels.
    – Jeroen
    Aug 17, 2016 at 8:49

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.