javascript

Making a case against using your theme for functionality

As I'm teaching some friends the basics of Drupal I see a common mistake, putting too much functionality into the theme. The real problem with this is simple: the site's look and feel may change with or without the site's functionality. If you're using a custom theme, it's tempting to throw functionality right into page.tpl.php and call it a day. But you're setting yourself up for headaches. Trust me, I know from experience.

Write your own jQuery accordions in 7 lines of code.

A lot of times, people want very specific functionality out of a jquery menu. There are at least 5 or 6 decent jQuery accordion menu plugins out there. But they're all overkill in my opinion.

A jQuery accordion can be as little as 3 lines of code. Here's one in 7 lines of code. And if you do some chaining, probably even less.

$('#accordion li ul').hide();
$('#accordion li a').click(function(){
	$(this).parent().addClass('selected');
	$(this).parent().children('ul').show('fast');
Syndicate content