Recent Topics

1 Jan 11, 2011 17:23    

My b2evolution Version: 3.3.3

Is there a way to display custom headers or sidebars based on the category being viewed inside of a blog? Like a category skin or template?

2 Jan 11, 2011 22:03

Use the following code to check what category you are on, put the code in index.main.php after skin_init( $disp ); call.

global $Messages, $cat;
if( !empty($cat) && is_numeric($cat) )
{
	switch($cat)
	{
		case 44: // Category with ID 44
			$Messages->add('Viewing category #44');
			add_css_headline('.bPost { color:red }'); // add custom CSS styles
			break;
		
		case 55:
			$Messages->add('Viewing category #55');
			add_css_headline('.bPost { color:green }');
			break;
		
		default:
			$Messages->add('Viewing other categories');
	}
}
else
{
	$Messages->add('Not a category');
}

Later in skin you can use this to display conditional HTML


global $cat
if( !empty($cat) && is_numeric($cat)  )
{
	if( $cat == 567 )
	{
		echo '<p>Some HTML goes here</p>';
	}
	elseif( $cat == 123 )
	{
		echo '<h2>Whatever</h2>';
	}
}


Form is loading...