Field formatters provide the ability to specify one or more field types to which they may apply, and they do not appear as options for field types that are not on the list.
I would like to propose something similar for style plugins, so that defining a style looks like this (where the 'content type' item is new):
$plugin = array(
'title' => t('My menu plugin'),
'content type' => array('menu_tree'),
'description' => t('For styling menus.'),
'render pane' => 'my_menu_render_pane',
'pane settings form' => 'my_menu_settings_form',
'hook theme' => array(
'my_menu_pane' => array(
'template' => 'my-menu',
'path' => drupal_get_path('module', 'mymodule') . '/plugins/styles/my_menu',
'variables' => array(
'content' => NULL,
'settings' => NULL,
),
),
),
);
Patch is forthcoming.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | panels-n2320045-18.patch | 1.71 KB | damienmckenna |
| #15 | panels-style-plugin-type-subtype-2320045-15.patch | 1.36 KB | japerry |
Comments
Comment #1
bbinkovitz commentedPatches for D7 and D8 versions attached. They're pretty much identical because it doesn't look like the code that handles this part of Panels has changed between the two versions.
To test, make a style plugin that has an array with specified content type(s) (e.g. "menu_tree" or "panels_mini" or whatever you want it to apply to).
Then go to add your style plugin to some panes of different types. It should appear as an option on panels that match one of the types you specified, and it should not appear as an option on panels that do not match any of the types you specified. It should appear on all types of panels if none was specified in the plugin.
Comment #2
bbinkovitz commentedComment #4
bbinkovitz commentedComment #6
bbinkovitz commentedQueued for retesting with the correct version.
Comment #8
bbinkovitz commentedNot sure what's up with the "0 passes". Re-testing is obviously not causing any change.
Comment #9
robeano commentedI successfully tested the D7 patch: https://www.drupal.org/files/issues/panels-style-plugin-types-1249340-1-...
Here's how:
I tried several types of panes including 'block', 'entity_field' and 'views'. Here's an example of my plugin to work with a menu placed as a block. The 'block' content type is what is offered when adding a menu straight from Core as a pane.
This worked so that when I placed a View pane, then my style plugin was available when setting a style. Other types of panes like 'block' and 'entity_field' did not include my plugin in the list of style plugins available.
I have not tested the D8 patch.
Comment #10
ashrafabedI have successfully tested the D7 patch. I believe that it should be committed.
In my use case, I have styles that require being filtered more specifically than type. i.e. instead of a style being restricted to all mini panels, it needs to be restricted to specific mini panels. This patch could easily be extended to include the existing panel property of 'subtype' in the exact same way.
Attached is a D7 patch extending the existing patch slightly to include subtype as well as type.
Sample usage:
Note: I believe that this patch, which includes type and subtype, should be included. But even if this patch is not included, I vote to include the previously submitted patches.
Comment #11
guedressel commentedThank you ashrafabed. Your patch works great! Sub-type support is essential in our project.
Comment #12
mglamanOnly nitpick is possibly changing key to "content types" and "sub types". Also, what if the content types and sub types were defined like the following:
Either way, it works as is. Makes me happy. Will definitely improve our customer user experience by providing useful pane styles targeted at specific elements.
Comment #14
mrjmd commentedComment #15
japerryI've updated the variables. I think this is the right patch to commit but want a second glance at it.
Hiding the D8 patches. They won't ever be relevant to d8 as panels is totally re-written.
Comment #16
damienmckennaToo bad there's nowhere to document to list this new attribute :-\
I renamed the first variable to 'content types' because the other Panels/CTools plugin attributes use spaces instead of underscores.
Comment #17
muschpusch commented@Damien i think you attached some other permission related patch from #1699432
Comment #18
damienmckennaWhoops! X-)
Leaving this up to japerry to decide what approach to use.
Comment #19
Chris CharltonIs this pushed to Panels 3.6? Or 3.5.1?
Comment #20
albert volkman commentedSeeing as how this is still an open issue, the answer is "neither" :)
Comment #21
damienmckennaThis didn't get into 3.5 so lets bump it to 3.6.
Anyone care to give it a good review and push it to RTBC?
Comment #22
damienmckennaThis was not added to 3.6 after all. Taking it off the schedule until japerry gets to review it or someone RTBC's it.
Comment #23
japerryDrupal 7 is no longer supported, closing.