How to trigger a Rule when content is viewed with Panels activated?
You should use Rules Bonus Pack which allows to create a new event when a panel variation is loaded.

Detailed instructions:


Download Rules Bonus Pack and enable "Rules Bonus: Miscellaneous" sub module.
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".
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.

Example:

function yourcustommodule_ctools_render_alter(&amp;$info, &amp;$page, &amp;$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']-&gt;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'])]-&gt;data;

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

}


Happy coding :-)