The shortcode api indicates there can be an 'attributes callback' for each shortcode. That callback is used by the Shortcode WYSIWYG module to render a form element to provide the attributes for each shortcode. None of these attributes are currently populated so there is nothing to see when you use the WYSIWYG module, and it takes some digging to even figure out what is expected. Populating these values will make it more clear how the module works and how it can be extended if you want to create custom shortcodes.
Attached is a patch that populates these values for each shortcode. When used with the Shortcode WYSIWYG module you will now see a little form element where you can provide each possible attribute.
In the process of doing this I found that the original code intention wouldn't work exactly as it should. The system is designed such that each form element would have a simple name like 'class' and use Drupal states system to hide or show itself only when its shortcode is selected. But if you have multiple items with the same name (like 'class') the states system doesn't correctly hide the duplicated elements. So I adjusted the original intention slightly and prefixed each attribute with the shortcode name, which makes each element unique.
For this to work right the Shortcode WYSIWYG module then needs to strip that prefix off before inserting the shortcode. I'm going to provide a patch on that module as well.
Other than that, this should be pretty self-explanatory.
Comment | File | Size | Author |
---|---|---|---|
populate-attributes.diff | 19.49 KB | KarenS | |
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedSee https://www.drupal.org/node/2312375 for the associated fix to Shortcode WYSIWYG.
Comment #2
Denes.Szabo CreditAttribution: Denes.Szabo commentedComment #4
Denes.Szabo CreditAttribution: Denes.Szabo commentedDear KarenS, thanks for your work.
Your patch committed.