On applying some customisations (changes in ipe title button) this code overwrite changes for IPE edit button.

/**
 * Preprocess the panels_ipe_toolbar to change text for IPE buttons
 */
function panopoly_magic_preprocess_panels_ipe_toolbar(&$vars) {
  foreach ($vars['buttons'] as $panel_context_id => $panel_context) {
    foreach ($panel_context as $button_name => $button) {
      switch ($button_name) {
        case 'panels-ipe-startedit':
          $vars['buttons'][$panel_context_id][$button_name]['#title'] = t('Customize this page');
          break;
        case 'panels-ipe-change-layout':
          $vars['buttons'][$panel_context_id][$button_name]['#title'] = t('Change this layout');
          break;
      }
    }
  }
}

Patch should solve this issue

Comments

chewie’s picture

chewie’s picture

Issue summary: View changes
chewie’s picture

Component: User interface » Code
chewie’s picture

StatusFileSize
new10.57 KB
chewie’s picture

StatusFileSize
new10.52 KB
dsnopek’s picture

Status: Needs review » Needs work

Thanks!

Please refrain from including whitespace or coding style fixes in unrelated code. While we'd like to fix these issues one day, committing this could prevent other patches to panopoly_magic from applying. Once the number of open patches is low enough, we'll make a "coding style pass" and fix all these issues at once. :-)

chewie’s picture

StatusFileSize
new716 bytes
chewie’s picture

chewie’s picture

chewie’s picture

Status: Needs work » Needs review
chewie’s picture

Status: Needs review » Needs work
chewie’s picture

Status: Needs work » Needs review
StatusFileSize
new751 bytes
dsnopek’s picture

Status: Needs review » Needs work
+++ b/panopoly_magic.module
@@ -1238,7 +1238,9 @@
-          $vars['buttons'][$panel_context_id][$button_name]['#title'] = t('Customize this page');
+          if (empty($vars['buttons'][$panel_context_id][$button_name]['#title'])) {
+            $vars['buttons'][$panel_context_id][$button_name]['#title'] = t('Customize this page');
+          }
           break;

Hrm. Unfortunately, I don't think that array key is ever going to be empty, so that code will never run. :-/

Also, I'm not entirely sure that code is necessary in the first place because the panels_ipe is already setting that button title to "Customize this page". The second one is necessary because the default is "Change layout" (without "this").

However, if the goal is for your preprocess function to take precedence over panopoly_magic's, you can reorder the preprocess functions using hook_theme_registry_alter():

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

By doing that in your module, you can avoid patching Panopoly all together!

dsnopek’s picture

I tried to track down the reasoning for that preprocess function and it comes from the initial commit of panopoly_magic. I'll e-mail @populist to see if he remembers why that's there, but personally, I'd be for removing the function entirely! All it does is add a "this" to "Change this layout", which is a suspect change at best. :-)

populist’s picture

I believe that function was added by the chief (@merlinofchaos) as part of an effort to make the IPE bar more themeable - https://www.drupal.org/node/1249332. We added the function to Panopoly Magic to match the original designs.

No worries from me if we want to remove the logic to make Panopoly more extendable, as long as the default labels are human friendly.

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new1.01 KB

Thanks, @populist!

Yeah, the default labels are almost the same except "Change this layout" is "Change layout" which I think is totally fine. Here is a patch that removes the preprocess and lets the default labels shine through! I'll make sure our automated tests still work and then commit.

dsnopek’s picture

  • dsnopek committed 3f5a1cd on 7.x-1.x authored by Chewie
    Issue #2410921 by Chewie, dsnopek: Avoid overwriting title of IPE buton
    
dsnopek’s picture

Status: Needs review » Fixed

Tests passed! Thanks to @Chewie for pushing this and @populist for the background info! Committed. :-)

dsnopek’s picture

Project: Panopoly Magic » Panopoly
Version: 7.x-1.9 » 7.x-1.x-dev
Component: Code » Magic

Moving to Panopoly issue queue... Not sure how this got here!

Status: Fixed » Closed (fixed)

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