Collapsiblock in other themes--documentation

NathanRAFT - September 3, 2006 - 16:38
Project:Javascript Tools
Version:HEAD
Component:Collapsiblock
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

The following block.tpl.php works fine....

  <div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
    <h2 class="title"><?php print $block->subject; ?></h2>
    <div class="content"><?php print $block->content; ?></div>
</div>

This does not work...(From Pushbutton)

<div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>">
  <div class="title"><h3><?php print $block->subject ?></h3></div>
  <div class="content"><?php print $block->content ?></div>
</div>

I can use the first one in pushbutton but it looses the block icon. (Also can change the h2 to h3 and it works fine.)

Here is the function from "collapsiblock.module,v 1.1.2.5 2006/07/13 20:16:40 nedjo Exp" that seems to be controlling this.

function collapsiblock_submit($form_id, $edit) {
  $settings = variable_get('collapsiblock_settings', array());
  $settings['block-' . $edit['module'] . '-' . $edit['delta']] = $edit['collapse_type'];
  variable_set('collapsiblock_settings', $settings);

I have tried to fix it myself to post here but I just can't seem to make it work.

Can someone post a fix for this and/or add this to the next commit?

Thanks!

#1

nedjo - September 3, 2006 - 18:27

I don't understand exactly what the issue is. Can you explain again?

#2

NathanRAFT - September 4, 2006 - 15:54

Yeah... Sorry for the lack of detail.

Collapsiblock does not work on blocks in some of the standard themes. For example Pushbutton theme has the icon and underline for each block title. When I turn on collapsiblock there is no expandibility( i.e. collapsed.png does not show) unless I change the block.tpl.php file to match that of bluemarine as in the first code I noted. When I do this the expansion works but looses the icon and underline standard to the pushbutton theme.

It appears that the way collapsiblock.module is looking for the blocks is specific to the div class in the block.tpl.php file and as you can see from the pushbutton block.tpl.php example shown above "This does not work...". Looks like someone got fancy when writing the block template with pushbutton inorder to show the icon and line below the block title.

I tried to change the $settings on lines 78-82 of collapsiblock.module to match that of pushbutton block.tpl.php but I just don't know enough to make it work.

I hope this helps! If you need more info please let me know.

Great feature by the way! A great way to keep things from getting too cluttered... a big problem on many drupal sites.

#3

trish t - October 2, 2006 - 11:23

Thanks very much for posting this. I just encountered the same thing using the delicious zen theme.

For this theme, in block.tpl.php I removed a div class container <div class="blockinner">  </div> to make it work.

#4

dman - January 17, 2008 - 01:12
Title:Collapsiblock in other themes--pushbutton» Collapsiblock in other themes--documentation
Version:4.7.x-1.x-dev» HEAD
Status:active» needs review

How about this? You don't HAVE to modify your theme block.tpl.php.
The code gives you the provision to redefine the selector. ... It simply didn't tell you how to do so.

Attached is the following addition to the README

Configuration
------------------------------------------------------------------------------
To get collapsiblock working on custom themes, in cases where the block titles
are NOT h2, you need to add a setting that defines an appropriate css selector
as a 'titleSelector' parameter for jstools.

EG, in a theme that has a block.tpl.php that uses h3, not h2 as the title:
//-------------------------------------
/**
* Setting for collapsiblock, specific to this theme
*/
function collapsiblock_theme_data() {
return array(
'titleSelector' => 'h3',
);
}
//-------------------------------------

This function can be either in a file named
jstools/collapsiblock/theme/yourtheme.php
or inside
yourtheme/template.php

See the jstools/collapsiblock/theme folder for examples.

AttachmentSize
collapsiblock_readme.patch 1.46 KB

#5

nedjo - January 17, 2008 - 02:14
Status:needs review» reviewed & tested by the community

Thanks dman. I've assigned you CVS access for jstools. Pls go ahead ahd apply this, first to HEAD and then to the DRUPAL-5 branch.

#6

NathanRAFT - January 17, 2008 - 02:56

Thanks a lot!

#7

dman - January 17, 2008 - 03:11

Actually, on further investigation (fresh check-outs) It seems that documentation to this effect was already added last month. I could have sworn that I updated everything before attempting my patch.

Doh! Ignore that ;-)

However.

It seems the behaviour I find useful (having the ability to add a theme-specific module tweak into my custom theme template.php file) and figured out and documented, has been disabled in recent releases.
It used to work :-)

When developing templates, I don't want to be putting theme-named stuff into the distributed module directory. Although I see why it was done for core themes.
I need to be able to rename my theme to theme_v2, and carry on. Having the behaviour quietly disappear because there was now no collapsiblock/themes/mytheme_v2008.php file was a real time-waster for me.

It really bit me - in a high profile (celebrity) presentation yesterday - because I'd frozen one version of the theme and cloned it to another version name.

When the collapsiblock-specific tweak was part of my theme configs, this wasn't a problem.
Um, I'm rambling.

Point is ...

<?php
function jstools_theme_data($module) {
  return
jstools_theme_include($module) ? module_invoke($module, 'theme_data') : array();
}
?>

is now too conservative.

I think (although I may not have the full picture yet, so I'm open to discussion) that attempting to module_invoke() (which is a safe action) need not only depend on the successful inclusion of theme-specific snippets found in the jstools dir. A theme can (and often should) supply them itself so the desired hook may already be available.

... I'm just trying to understand a roadmap for integration with arbitrary, custom, themes ...

If a unique theme departs from the Drupal 'standard' elements, then it needs to play catch-up with module requirements. It's not a modules job to chase every theme.
... so the module would be good if it allowed the theme to add its own parameters ... without requiring modifications to the module directory. Even though the theme-snippet idea was pretty good.

#8

aexl_konzepto.net - March 24, 2008 - 18:14

same problem. subscribing.

#9

najibx - March 31, 2008 - 16:06

Comment #4 is not working as only H2 selector is working. Furthermore, the example given is actually theme_name.inc not theme_name.php

#10

najibx - March 31, 2008 - 16:26

Opss .... the mythme.inc must be placed in something like ... not in the theme directory. This what dman has been talking about.

/sites/all/module/jstools/collapsible/theme

#11

aexl_konzepto.net - March 31, 2008 - 22:11
Status:reviewed & tested by the community» needs review

OK, i solved the issue for me. It seems patch #4 is not completely correct.

- placing the customisation function collapsiblock_theme_data() in /sites/all/templates/[yourtheme]/template.php does NOT work for me,
- placing the customisation function collapsiblock_theme_data() in /sites/all/modules/jstools/collapsiblock/theme/yourtheme.inc DOES work for me

below is the changed README part. Please review someone.

------------
Configuration
------------------------------------------------------------------------------
To get collapsiblock working on custom themes, in cases where the block titles
are NOT h2, you need to add a setting that defines an appropriate css selector
as a 'titleSelector' parameter for jstools.

EG, in a theme that has a block.tpl.php that uses h3, not h2 as the title:
//-------------------------------------
/**
* Setting for collapsiblock, specific to this theme
*/
function collapsiblock_theme_data() {
return array(
'titleSelector' => 'h3',
);
}
//-------------------------------------

This function must be in a file named
jstools/collapsiblock/theme/yourtheme.inc

See the jstools/collapsiblock/theme folder for examples.

#12

dman - April 1, 2008 - 07:21

Correct.
That feature (publishing theme-specific configs in your theme dir) stopped working at some point. :-(
The fix is putting theme-specific patches in the module folder. :-(

I guess it's to do with the load order (theme is invoked quite late in the page-build process, after the modules have done most of their work). There is a reason for this, a good one. BUT

I wish there was a proper fix that lets this theme-pref influence the modules behaviour. Perhaps if the js-printer was run through a theme call it would all fall into place.

#13

UnicornSong - October 15, 2008 - 22:48

Surely adding custom functions within the module folder opens up loss of functionality when the module is updated? does this really fix the issue or create a new one?

#14

youkho - February 1, 2009 - 05:09

#11 Works like a charm was missing the collapsiblock on framework theme but now it works
thanks for the help

#15

vtldeveloper - March 18, 2009 - 16:59

#11 tells you how to correct the problem if your theme block.tpl.php is compatible.

I had the titleSelector set up correctly but the block would display open and the toggle wasn't working.

After replacing my templates theme block.tpl.php with the original posters code as a test, the functionality worked.

This worked

   <div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
    <p class="title"><?php print $block->subject; ?></p>
    <div class="content"><?php print $block->content; ?></div>
</div>

this didn't

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="block block-<?php print $block->module ?>">

<?php if (!empty($block->subject)): ?>
  <div class="caption"><p><?php print $block->subject ?></p></div>
<?php endif;?>

  <div class="box"><?php print $block->content ?></div>
</div>

Depending on your theme, setting the titleSelector correctly should work, but if not, try doing some tests with your block.tpl.php.

#16

volocuga - July 5, 2009 - 22:45

Yes,I had the same issue too.

For standart block.tpl.php content it works good,but if you'd try something like

<div id="block-container">
<h2><?php print $block->subject; ?></h2>
<div id="block-content><?php print $block->content ?></div>
</div>

in your custom block.tpl.php,it does not work."h2" is defined in mytheme.inc as well

 
 

Drupal is a registered trademark of Dries Buytaert.