When adding new custom content to a panel pane, you are given the option to "Use context keywords" allowing token-like replacement of keywords with context values. I found it useful in a recent project to allow this for FPP as well. Patch forthcoming.

Files: 
CommentFileSizeAuthor
#14 2018329-14-FPP_Context_substitutions.patch5.77 KBbrunodbo
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#13 2018329-13-FPP_context_substitutions.patch6.36 KBmikeker
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#10 fieldable_panels_panes-context_substitutions-2018329-10.patch6.14 KBbarraponto
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fieldable_panels_panes-context_substitutions-2018329-10.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#8 fieldable_panels_panes-context_substitutions-2018329-8.patch6.14 KBbarraponto
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#2 2018329-2-FPP_context_substitutions.patch4.76 KBmikeker
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#2 2018329-2-interdiff.txt1.15 KBmikeker
#1 2018329-1-FPP_context_substitutions.patch4.74 KBmikeker
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Comments

mikeker’s picture

Status:Active» Needs review
StatusFileSize
new4.74 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
mikeker’s picture

StatusFileSize
new1.15 KB
new4.76 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Fixes undefined index error when adding FPPs in a non-context situation (eg: admin/structure/fieldable-panels-panes/manage/fieldable-panels-pane/add).

bjalford’s picture

Issue summary:View changes
Status:Needs review» Needs work

I can now see the checkbox but it doesn't save the value when selected. Going back into the pane and it's unchecked

mikeker’s picture

@bjalford, Did you run update.php (or drush updatedb)? This patch introduces a DB schema change to save the settings.

barraponto’s picture

I get empty contexts even though there is a context in my panel :/

Warning: Invalid argument supplied for foreach() in ctools_context_keyword_substitute() (line 639 of DRUPAL/profiles/quequere/modules/contrib/ctools/includes/context.inc).

btw, I also get issues for fields that are not text-type, I've fixed with a !empty check.

merlinofchaos’s picture

The reason for the empty contexts is that a content type only receives requested contexts unless it sets 'all contexts' => TRUE in its definition. Then it will always receive all contexts. Since FPP shouldn't be requesting contexts that I can think of, this should be fairly safe to set.

barraponto’s picture

@merlinofchaos actually, 'all contexts' => TRUE is set: http://drupalcode.org/project/fieldable_panels_panes.git/blob/refs/heads... :/

Right now I'm monkeypatching ctools to call fieldable_panels_panes_fieldable_panels_pane_content_type_content_type when needed (in ctools_content_select_context because calling it in ctools_content_select_context always led to out-of-memory errors).

barraponto’s picture

StatusFileSize
new6.14 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

I figured the 'content type' key in plugin definition was missing (not sure if this is the proper way to declare it though). Then I found out that fieldable_panels_panes_fieldable_panels_pane_content_type_content_type and fieldable_panels_panes_load_entity would call each other in a loop, so I fixed it by taking a shortcut to _fieldable_panels_panes_load_entity.

Now the contexts are passed to the pane and everything works. I've fixed a small issue with fields that don't set the #markup property, such as link fields.

barraponto’s picture

Status:Needs work» Needs review
barraponto’s picture

StatusFileSize
new6.14 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fieldable_panels_panes-context_substitutions-2018329-10.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Added support for title links as well.

Status:Needs review» Needs work

The last submitted patch, 10: fieldable_panels_panes-context_substitutions-2018329-10.patch, failed testing.

mikeker’s picture

Status:Needs work» Needs review
StatusFileSize
new6.36 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Rerolled #10 against the latest -dev.

Also made some adjustments to how title substitutions work as that code has evolved (title now shows as a child element in addition to $block->title...?).

brunodbo’s picture

StatusFileSize
new5.77 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Reroll of #13 against latest dev.

chandimac’s picture

Works great for text fields. Is there a way to get this to work for image fields as well? I'm using the Media module and there is no way to add a token substitution through the UI.

B-Prod’s picture

Status:Needs review» Reviewed & tested by the community

Last patch works as expected.