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

dddbbb’s picture

Version: 7.x-1.2 » 7.x-1.3

I'm seeing this very same problem in ctools 7.x-1.3 as well.

@ijujym - Did you ever figure out a fix for this?

Tsubo’s picture

Category: support » bug

Same issue here. The substitution is made correctly but the errors are clogging up my dblog. Any suggestions?

merlinofchaos’s picture

Status: Active » Closed (works as designed)

You'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. :)

merlinofchaos’s picture

I 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.

dddbbb’s picture

CTools plugin tutorials here I come.