Was playing around today, and thought.. is it possible to create a collapsable block? Like My Yahoo, or Google's, say you click somewhere in the title of the block and it closes it to only show the title and not the content of the block, and click it again to open it. I would be useful for me on a couple sites where I want to have several custom blocks, but give users the control of if they want to see them or not.

Anyone have any ideas on how I could go about this, not a heavy programmer, but I've hacked enough drupal code to know my way around.

Thanks, m@

Comments

chx’s picture

you add the relevant JS to your theme. I am no JS guru to know how to this, but maybe some elements' display property should be switched between block and none.
--
Read my developer blog on Drupal4hu.

--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.

tomski777’s picture

Take a look at the LoginToboggan module, as it uses this functionality in one of its blocks: http://drupal.org/node/34309

><>tomskii
><>www.mutinyarts.co.uk

dreed47’s picture

Also, there is http://www.drupalart.org/togglediv

I also have an outlook bar type module that will allow you to put any block in a collapable panel bar. It's not ready for prime time yet but hopfully it will be in the next couple of weeks.

sangamreddi’s picture

Hi,

I have implemented fro login section of my site. U can check it on my homepage. If you click login the form appears.
This can be extended to all blocks too.

Sunny
www.gleez.com

tinycg’s picture

Thanks for all the suggestions guys, and so quickly. I'll report back with what I did, just in case anyone else is looking for a similar solution. Long live drup.

tinycg’s picture

I've gotten things close to working, and edited theme.inc to ID the content portion of a block, therefore attempting to keep the title visible when toggling the css div element.

However, it doesn't seem to take effect. To my knowledge theme.inc is the only place that is themeing blocks and can be overridden there. Anyone have any suggestions?

Once I can ID the content I should be all set. As for now I can only toggle the whole block, would love to just toggle the content in the block.

Thanks

dreed47’s picture

Not sure what drupal version you're running but I'm working on a 4.7 (HEAD) module that allows you to put blocks in a container (Block Bar) that would automatically allow toggling of the sub blocks.

You can see a screenshot here http://mycivicsite.com/bluemarine.png

The project is not yet up on drupal.org but you can see the code in the contrib/modules CVS repository http://cvs.drupal.org/viewcvs/drupal/contributions/modules/blockbar/

If you're not yet running 4.7 (HEAD) then at least the code will show you how I'm doing it. The module won't work in a pre 4.7 release but the concepts would be the same.

From the readme file:

The BlockBar module is a block module that acts as a container for other
Drupal blocks. The module builds an Outlook style collapsible menu
bar from the child blocks with each child block representing one panel
within the bar. Multiple BlockBars can be created. Each BlockBar can
be set with "sticky panels" which will remember the panel's open/close
state between page refreshes. Also, an option can be set that will only
allow one panel to be open at a time for a given bar.

jbernat’s picture

As for now I can only toggle the whole block, would love to just toggle the content in the block.

I installed the ADC theme in my test site days ago and I believe it does exactly what you are looking for. Although I have not yet examined it fully, it also appears to be a table-less CSS design that positions main content first in source.

http://drupal.org/project/adc

Jim
jim.bernatowicz.net