We have a custom mymodule
that calls mymodule_preprocess_node(&$variables)
hook. When we add ksm($variables);
to the hook, we are finding the message is printed multiple times (average has been 5x).
How to make mymodule_preprocess_node
run only one time?
I am needing to run this hook because I want to check to see if a field is populated with some value then perform some other logic.
Example:
function mymodule_preprocess_node(&$variables) {
$node = $variables['node'];
if(isset($node->get('field_link'))) {
// perform some logic.
ksm('in here'); // printed multiple times.
}
}
ksm('in here')
showing up five times.$node->nid
the same for each? And since you tagged 8, do you have render cache and/or Twig caching disabled?