According to the Help text for Pages PHP Code field "All contexts will be available in the $contexts variable." I used this $contexts variable while creating New custom content on a page and it works great with Use Context Keywords selected. But when I use similar code configuring visibility for content I get an unexpected '%' syntax error.
For example:
$project_status = '%node:field-proj-status';
return $project_status;
This works great for Create Custom Content with Use Context Keywords selected:
$project_status = %node:field-proj-status;
This generates a unexpected '%' syntax error (if I enclose it in ' ' it converts the variable to a text string) when you refresh the page with the new visibility configuration for it's content. Since there is no option to Use Context Keywords and the help text says "All contexts will be available in the $contexts variable." I'm assuming it's on by default but that doesn't seem to be the case.
Thanks for the great work, I love panels!
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedContexts are available via $contexts; the %substitutions are not run on this code. This isn't a bug, you're crashing because you create invalid PHP code.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedYOu can probably work around this like so:
$value = ctools_context_keyword_substitute('%node:field-proj-status', array(), $contexts)
Comment #3
blackclover CreditAttribution: blackclover commentedThank you. Works great!
Comment #4
dddbbb CreditAttribution: dddbbb commented#2 does work but it also produces Watchdog errors as per http://drupal.org/node/1781086
Comment #5
LTech CreditAttribution: LTech commentedHow would I use context to find the current stock level? I am using ubercart on my site.
I have a table uc_product_stock which has columns nid and stock.
I would like to run a database query to check the stock level for the current nid.
If the stock level is 0, hide the panel and if >0 then show the panel.
I've tried
$query = db_query("SELECT stock FROM {uc_product_stock} WHERE nid = '55' ");
dpm($query);
but nothing is coming back. How do I check the stock level?
Thanks
Comment #6
LTech CreditAttribution: LTech commentedIt worked using: