The function radix_preprocess_panels_add_content_link depends on an exact match with the link text in order to apply the correct styling to the links you see when you Add Content and choose a top-level category that has multiple pane types to add.
// If title is Add, assume we are rendering an 'Add' button for preview;
if ($vars['title'] == t('Add')) {
$title = '<i class="fa fa-plus"></i> ' . $vars['title'];
$button_classes = 'panels-modal-add-config btn btn-success btn-sm pull-right';
$vars['button'] = ctools_ajax_text_button($title, $vars['url'], $vars['description'], $button_classes);
}
The problem with this is that just plain "Add" is terrible link text, particularly in a context where there's more than one link generated the same way. In #2773683: Can't distinguish Add links on Add Content dialog I'm working on an accessibility and automated-testing fix for Panopoly that will break this function. The link text will no longer just be "Add," it will include the pane type label as invisible text. Something using strpos or preg_match should solve the problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | interdiff-2-4.txt | 1009 bytes | cboyden |
| #4 | radix-add-content-button-styling-2773717-4.patch | 993 bytes | cboyden |
Comments
Comment #2
cboyden commentedHere's a patch using strpos to check if the (translated) "Add" text is part of the title. I'm not sure it'll work if the translation for "Add" in a context where the pane type label is included isn't the same for all instances.
Comment #3
dsnopekHm. This isn't exactly right because the translation for
t('Add <span class="element-invisible">@widget_name</span>')might not actually containt('Add'). This is difficult to envision from an English-speaking perspective, but imagine a language where the word for 'Add' requires an object, sot('Add')becomes something like "Add it", and since the other string has an object it wouldn't have the "it" part.If we're going to keep comparing the title string to determine if this is the add button, we'd have to do something like:
However, the thing I'm not certain about is if we can get
$widget_namefrom somewhere in the current context...Also, we should probably have the patch check for both the new string and the old
t('Add')for people who want to update Radix, but aren't ready to update Panopoly.Comment #4
cboyden commentedThanks, I've updated the patch to use a new flag set by panopoly_magic in the latest patch in #2773683: Can't distinguish Add links on Add Content dialog.
Comment #5
dsnopekI haven't actually tested this, but the code looks great! Assuming this actually works, I think it's good to go - we just need to wait for the Panopoly Magic issue to be committed first.
Comment #7
dsnopek#2773683: Can't distinguish Add links on Add Content dialog just landed! Yay!
So, I've committed the Radix issue as well, since it'll work with Panopoly both before and after this change :-)