April 4, 20106 Comments

I think my post title is not clear and it’s really not possible to tell every thing in just a simple post title :P . Ok, I am taking about:
1. WordPress
2. Category menu in wordpress using wp_list_categories()

If you make a wordpress menu using category listing in wordpress then the html code will be like this

WordPress menu as category list
WordPress menu as category list(click image to see full)

In the above picture , you see same thing twice , firt one
1. when we are not in any category page(category archive page)
2. when we are in a category archive page , the active category list gets a extra class name “current-cat”
So my post is about when we are browsing any single post how can we mark the the category as “current-cat” that post belongs to so that the active category list can be styled using css.

So to do that I got a plugin (please check here) but i am not happy as the plugin put active class for anchor tag… Please check the plugin code.

function show_active_category($text) {
	global $post;
	if( is_single() ) {
		$categories = wp_get_post_categories($post->ID);
		foreach( $categories as $catid ) {
			$cat = get_category($catid);
			if(preg_match('#>' . $cat->name . '</a>#', $text)) {
				$text = str_replace('>' . $cat->name . '</a>', ' class="active_category">' . $cat->name . '</a>', $text);
			}
		}
	}
	return $text;
}
add_filter('wp_list_categories', 'show_active_category');

and here is my version

function show_active_category($text) {
global $post;
if( is_single() ) {
$categories = wp_get_post_categories($post->ID);
foreach( $categories as $cat )
{
//var_dump($cat);
if(preg_match('#
	<li class="cat-item cat-item-'.$cat.'">#', $text))
{
$text = str_replace('</li>
	<li class="cat-item cat-item-'.$cat.'">', '</li>
	<li class="cat-item cat-item-'.$cat.' current-cat">', $text);
}
}
}
return $text;
}
add_filter('wp_list_categories', 'show_active_category');

you can put the above your in your functions.php file and no need to install an extra plugin.

That’s it.

December 2, 200950 Comments

Change Log:

Update 14, January, 2010

WOW, This extension has been approved by JED Team. Pls visit it and place you rating.

Update 8, June, 2010(Must see)

  • Fixed a bug for php error, it was a typo error
  • Transition parameter was missing for slider, it’s fixed now
  • Download file is updated! Please reinstall or update the files only. Changes are in the mod_simplejoomlatabslider.xml, mod_simplejoomlatabslider.php and helper.php file

tabIf you check joomla1.5.x backend(joomla1.x had same) in any component or module configuration the right col accordian slider is common. In some components u should see tab too.To make such tab and slider is just so easy !

I think you are thinking about my post title, why I used the words “home made”. Because I am going to show you how u can make such a tab/slider module for front end just using joomla own resource. Joomla gives some execillent api to make html grid, tab, slider etc within a moment. JPane is such an api to make tab and slider. Here you will get some code example about how to make tab using JPane.

…continue reading Home made tab and slider module for joomla1.5

  • Go to top
    Go to top
feedback