Recent Topics

1 Jun 02, 2006 00:13    

Is there a way to incorporate a Selected or Active styling for the Categories list thats more flexible than the default *.

->Skin -> _categories.php

if( in_array( $cat_ID, $cat_array ) )
		{	// This category is in the current selection
			echo " *";


Can that echo call a CSS styling for the selected li?

Cheers

2 Jun 02, 2006 02:15

This isn't tested, but I think it should work. Go up a few lines from there and find:

echo $cat_line_start;


Replace it with

if( in_array( $cat_ID, $cat_array ) )
{       // This category is in the current selection
        echo '<li class="currentCat">;
} else {
        echo '<li>';
}

3 Jun 02, 2006 02:45

Nope, that cuts off the whole Category list and everything that follows it :)

New...

/**
	 * callback to display sublist element
	 */
	function cat_list_before_each( $cat_ID, $level )
	{	// callback to display sublist element
		global $blogfilename, $cat_array, $cat_line_start, $cat_line_checkbox;
		$cat = get_the_category_by_ID( $cat_ID );
		if( in_array( $cat_ID, $cat_array ) )
{       // This category is in the current selection
        echo '<li class="currentCat">';
} else {
        echo '<li>';
}
		if( $cat_line_checkbox )
		{
			echo '<label><input type="checkbox" name="catsel[]" value="'.$cat_ID.'"';
			if( in_array( $cat_ID, $cat_array ) )
			{	// This category is in the current selection
				echo ' checked="checked"';
			}
			echo ' />';
		}
		echo '<a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a>';
		if( in_array( $cat_ID, $cat_array ) )
		{	// This category is in the current selection
			echo " *";
		}

Original...

/**
	 * callback to display sublist element
	 */
	function cat_list_before_each( $cat_ID, $level )
	{	// callback to display sublist element
		global $blogfilename, $cat_array, $cat_line_start, $cat_line_checkbox;
		$cat = get_the_category_by_ID( $cat_ID );
		echo $cat_line_start;
		if( $cat_line_checkbox )
		{
			echo '<label><input type="checkbox" name="catsel[]" value="'.$cat_ID.'"';
			if( in_array( $cat_ID, $cat_array ) )
			{	// This category is in the current selection
				echo ' checked="checked"';
			}
			echo ' />';
		}
		echo '<a href="'.url_add_param( get_bloginfo('blogurl'), 'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name'], 'htmlbody').'</a>';
		if( in_array( $cat_ID, $cat_array ) )
		{	// This category is in the current selection
			echo " *";
		}

4 Jun 02, 2006 03:21

Fixed... just a missing '

echo '<li class="currentCat">;


echo '<li class="currentCat">';

5 Jun 02, 2006 05:54

Oops, sorry for the typo.

6 Jul 20, 2006 02:26

personman.

Is there any way this can be adapted to the Categories Plugin in 1.8?

I'm playing with it, with no success to date and simply need to know if I should stop banging around in that plugin :(

7 Jul 20, 2006 02:54

John, it can be done, but you'll need to edit the /plugins/_categories.plugin.php file. That will affect all of your blogs, but for this it probably wouldn't be a bad thing. (If it were, you could make a second category plugin and call that on the skins where you want it.)

This is the section you need to change:

        function callback_before_each( $cat_ID, $level )
        { // callback to display sublist element
                global $tab, $blog, $cat_array;
                $cat = get_the_category_by_ID( $cat_ID );
                $r = $this->params['line_start'];
                if( $this->params['form'] )                {       
                // We want to add form fields: 

I haven't tested this, but it should give you the currentCat class:

        function callback_before_each( $cat_ID, $level )
        { // callback to display sublist element
                global $tab, $blog, $cat_array;
                $cat = get_the_category_by_ID( $cat_ID );
                if( in_array( $cat_ID, $cat_array ) )
                {
                        $r = '<li class="currentCat">';
                 } else { 
                        $r = $this->params['line_start'];
                 }
                 if( $this->params['form'] )                {       
                 // We want to add form fields:

8 Jul 20, 2006 02:59

Thanks Danny
I like the idea of the second plugin... nice bit of lateral thinking for an issue I couldn't get my head around
Cheers mate


Form is loading...