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.

Comments

cboyden created an issue. See original summary.

cboyden’s picture

Status: Active » Needs review
StatusFileSize
new741 bytes

Here'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.

dsnopek’s picture

Status: Needs review » Needs work

Hm. This isn't exactly right because the translation for t('Add <span class="element-invisible">@widget_name</span>') might not actually contain t('Add'). This is difficult to envision from an English-speaking perspective, but imagine a language where the word for 'Add' requires an object, so t('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:

if ($vars['title'] == t('Add <span class="element-invisible">@widget_name</span>', array('@widget_name' => $widget_name))) {

However, the thing I'm not certain about is if we can get $widget_name from 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.

cboyden’s picture

Status: Needs work » Needs review
StatusFileSize
new993 bytes
new1009 bytes

Thanks, 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.

dsnopek’s picture

I 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.

  • dsnopek committed e79a631 on 7.x-3.x authored by cboyden
    Issue #2773717 by cboyden: Theming for Add Content links depends on...
dsnopek’s picture

Status: Needs review » Fixed

#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 :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.