There are quite a number of issues in the queue about themes or modules that don't work out of the box:
#1269202: Using Collapsiblock with Omega theme
#2531682: block configuration not saved with the founding ZURB theme
#2676932: Instructions for Bootstrap Drupal Theme
#1937552: Collapsiblock does not collapse when the block has no div class content like in Zen theme.
#2332401: Incomplete theme settings retrieval
There must be a way to address all of these problems in a sensible, extensible way.
SolutionsPersonally I think #4 is the way to go.
Method 1 - JS selectors (current method)
-
Use a per-theme setting where the user can tell collapsiblock what the selectors are for their theme
-
These settings are passed directly to the JS which applies all settings on page load
Pros
-
Very flexible
-
Very simple to code
-
Gives user complete control
Cons
-
Doesn’t allow blocks to be rendered already collapsed - causes UI flash on slower loads
-
Requires users to understand template files - it’s clear that many users of this module do not
Method 2 - Inject selectors in preprocess
-
Inject collapsiblock classes into blocks in a preprocess function, such as in title_attributes and content_attributes
-
Just expect the correct selectors to be there and hard-code them into the JS
Pros
-
Should be more extensible and apply to more base themes
Cons
-
Themes all seem to use different template files and preprocess functions. Some use the $classes variable and some use $attributes in their template files… usage varies greatly
-
Lots of contributed themes do not include a wrapper for the content section of the block, making it very difficult to inject a class into anything that will collapse properly
Method 3 - JS with theme detection
-
Use method 1
-
Add some default theme-based settings that can be chosen by the user, like a link that says “I’m using Omega theme” or a dropdown box of themes
-
Maybe try to detect the default theme/base theme and automatically choose the right selectors on install
Pros
-
Better for beginners, less knowledge required
-
Only need to change the defaults for themes that don’t use the Drupal default classes
Cons
-
Still requires configuration
-
High maintenance, there are a LOT of themes out there
Method 4 - Base everything around the title instead of the block
-
Inject collapsiblock title wrapper into title_prefix and title_suffix
-
Use JS to collapse/expand siblings of the title element instead of looking for a content wrapper
Pros
-
Removes the need for a block wrapper and a content wrapper
-
All of the themes that were complained about not working in the issue queue use title_prefix and title_suffix
-
Allows the module to set a specific ID on block titles as they almost never have their own ID
Cons
-
There are probably many custom themes out there that have omitted title_prefix and title_suffix - though it seems like bad practice to me
-
Your input here?
Comment | File | Size | Author |
---|---|---|---|
#5 | version-1_version-2.diff | 12.99 KB | darvanen |
Comments
Comment #2
darvanenComment #3
darvanenI decided to go with method 4 and have pushed changes to 7.x-2.x-dev.
Comment #5
darvanenFor review purposes.
Comment #6
darvanen