Currently, the same piece of code used to theme the different boxes is repeated inside each layout plugin. In addition, if one wishes to change the appearance of all boxes, one has to override the layout theme function(s).

I've attached a patch which delegates the responsibility of theming the boxes themselves to a separate function. This makes for better software engineering and prevents the excess theme overriding mentioned above.

CommentFileSizeAuthor
mysite.patch10.9 KBelectricmonk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Category: bug » task

That's a really good patch.

electricmonk’s picture

It seems to work OK for me, but I'm only using the 'columns' layout. I hope that there weren't any small differences between the way boxes are rendered in the different layout plugins.

agentrickard’s picture

I don't believe so. I think it was all just copy/paste.

The only reason for keeping the code separate is if people want to make changes to one layout but not another.

electricmonk’s picture

Ok, so my patch is definitely a good idea - they can still do that by overriding the box theming function in their template file or elsewhere.

As a general rule, I strongly encourage using multiple layers of abstraction in order to allow users to override stuff without having to duplicate whole pages worth of functionality.

agentrickard’s picture

Status: Needs review » Needs work

And if users want to re-theme one layout but not the others? We should probably pass a $layout parameter to the theme.

Understand that I agree with you, this is just a very early module that I wrote. I was surprised and pleased to get it to work at all.

electricmonk’s picture

In this case, I would use a mediator theming function, which would look something like this: (I'm at home now, so I don't have the code in front of me)

function theme_mysite_box($args...) {
   $func = theme_get_function('mysite_box_' . $layout);
   if ($func) {
      $func($args...)
   }
   else {
     // default behavior, or a call to a default function
   }
}

What do you say?

agentrickard’s picture

Works for me.

electricmonk’s picture

Hmmm... so, are you waiting for me to make those changes, or are you going to implement them yourself sometime in the future?

agentrickard’s picture

Waiting for a patch. This module is not in active development, and this is not critical.

electricmonk’s picture

What I mean is - are you waiting for a patch submission by myself?

agentrickard’s picture

Yes.

agentrickard’s picture

Status: Needs work » Closed (won't fix)