By tinycg on
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
theme
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.
Take a look at the
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
or look here
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.
Implemented for login
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
Very Cool.
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.
Can't ID Block Content
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
Not sure what drupal version
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:
Take a look at the ADC theme
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