Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm useing ctools_context_keyword_substitute() in a PHP content block in Page manager panel. A test code looks like this:
$value = "%node:field_name";
$test = ctools_context_keyword_substitute($value, array(), $contexts);
echo $test;
The substitution is made correctly how ewer it results in warning notice:
Notice: Undefined variable: contexts in eval() (line 4 of /modules/php/php.module(80) : eval()'d code).
Warning: Invalid argument supplied for foreach() in ctools_context_keyword_substitute() (line 628 of /sites/all/modules/ctools/includes/context.inc).
And this error in log:
Warning: Invalid argument supplied for foreach() in ctools_context_keyword_substitute() (line 628 of /sites/all/modules/ctools/includes/context.inc).
Comments
Comment #1
dddbbb CreditAttribution: dddbbb commentedI'm seeing this very same problem in ctools 7.x-1.3 as well.
@ijujym - Did you ever figure out a fix for this?
Comment #2
Tsubo CreditAttribution: Tsubo commentedSame issue here. The substitution is made correctly but the errors are clogging up my dblog. Any suggestions?
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedYou're passing $contexts to a function. The error says that on line 4, $contexts is not defined, and that's the line in your PHP code. The error indicates that you don't have a $contexts variable to pass.
When using the PHP filter, it is impossible to get variables into it; so you're trying to reference a variable that doesn't exist. This is a bug, but it's a bug in your code. :)
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedI don't actually know how your substitution could possibly work correctly since there are no contexts available. You probably want to put this in a custom content pane, which can then turn on substitutions. Either way, there's no way I can pass a $contexts variable into custom PHP code for you; the only way for you to get that is to actually write a proper content type plugin and use that.
Comment #5
dddbbb CreditAttribution: dddbbb commentedCTools plugin tutorials here I come.