By allen074 on
I am curious if it is possible to create a block like the one on this page - it is on the right side of the page and says "Today's Most Popular Stories" then there are 3 tabs - i would love to do that on my site. is it possible?
http://www.ibtimes.com/articles/20061009/anti-spam-lawsuit.htm
thanks!
Comments
morning bump
morning bump
Is it possible? Definitely.
Is it possible? Definitely. I've found almost no limitations on what can be achieved with Drupal. It's just a matter of implementing it into your theme. I haven't run into a module to make it easy if that's what your looking for.
Here's something to get you started. You should be comfortable with working in your template files. They both require jquery -which will be included in Drupal 5. You can include them manually though.
http://sputnik.pl/code/files/js/jquery/auto/jquery_auto_demo.html?test=two
http://www.stilbuero.de/2006/05/13/accessible-unobtrusive-javascript-tab...
–joon
thanks - but how do i get
thanks - but how do i get the tabs to hit the drupal blocks?
thats my worry - i have no idea how to do that part!
thanks
Warning...Long.
It's a bit more complicated than I thought it would be. Those tabs need to be structured in a very strict way. I played with the one from stilbuero.
Structure we need:
But the blocks being output from drupal would be closer to this times the number of blocks:
The titles are grouped with the content so it just won't work. The titles have to be grouped into
<li>one after the other. But jQuery does have the ability to modify DOM elements so it can be restructured. Here's what I came up with. I hope I can make this clear since it's a bit convoluted.First you have to dedicate a block region to this tabbing behavior. Lets say we it's called tab_block_group. This can be modified inside the template.php file. Then inside your page.tpl.php file you would have something like this placed wherever it makes sense.
The div#tab-block-container created here will contain the tabs and $tab_block_group will print out the blocks for this region.
Download jQuery.js and the jQuery.tabs.js files and include them in the head of the page.tpl.php template. We'll do the same with the style sheets -included with the tab script. All the files has to be in your theme folder.
/drupal-install/themes/your-theme/..
There is a conflict with autocomplete.js and jQuery so you can disable it whenever autocomplete.js is loaded. It's a cheap workaround but if you don't want this restriction then look here.
http://drupal.org/node/88979
Right above the
</head>-closing tag inside page.tpl.php, paste this in.Now open your block.tpl.php file. I don't know how yours is structured so I'll just post a simplified version of mine:
The block gives it's normal output when it is not part of the tab region. The title is turned into a link so it can activate the tabs. It's going to look ugly so it's up to you to style it to fit your theme.
Go in and setup your blocks from your admin pages. You can order them there and fill as many as you want. Each will have its' own tab.
I tried it on my site that's in the middle of being redesigned. -will break horribly in IE Scroll all the way to the bottom.
http://beta.dvessel.com
jQuery is sick! There's so much more that can be done.
–joon
Very impressive
A tidy solution to a nice question, I'd say.
Brilliantly presented. I nominate this for a snippet page.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
wow - i cant wait to try
wow - i cant wait to try this out in the next day or two - that is some solution - thank you!
Thanks, that sounds like a
Thanks, that sounds like a good idea. I think I'll do that.
@allen, tell us if it worked out. Good luck.
Oh, and you might want to strip out the comments. Some of it is out of place and it will render out on your pages. -duh!
–joon
Just found a better way to
Just found a better way to do this. No need to modify the block template. As long as the outer containing div block outputs a unique ID and the subject has a class of "title" it will work.
Transplant this in with the other code.
I tried to make it as compact as I could. If anyone has ideas to make it more efficient that'd be great.
–joon
Just posted to the handbook
Just posted to the handbook page. Use those instructions.
http://drupal.org/node/89338
–joon
good one.
It would be nice if it could start off with a screenshot or at least a diagram of what it's trying to achieve - that's not very clear from context.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
I completely agree with you.
I completely agree with you. Unfortunately I can't post an image. Just filed an issue about it but I'm not holding my breath. Will try to come up with another solution to make it more clear when possible.
–joon