Recent Topics

1 Feb 20, 2007 18:33    

My b2evolution Version: 1.9.x

HI,
I know nothing about pHP, so I hope someone in here can help me. I want to show my categories for each post as a list, so that each category will be surrounded by <li></li>.

Just like it is shown in the sidebar with the use of

$Plugins->call_by_code( 'evo_Cats', array(	// Add parameters below:
			) );


I just want to only show the categories that are associated woth that particular post.

the code I have tried to modify is

<?php $Item->categories(); ?>

Right now my categories are shown like: category, another category, the third category.

I want them to show like:
<li>category</li>
<li>another category</li>
<li>the third category</li>

:: Kasper

2 Feb 20, 2007 19:25

<?php 
$Item->categories( '#', '<ul><li><strong>', '</strong></li>', 'hide', 'hide', 'hide', 'hide', '' );
$Item->categories( '#', 'hide', 'hide', '<li>', '</li>', '<li>', '</li>', '' );
echo '</ul>';
?>


What it's doing is putting your main category instead of numerical order so that you can get your <ul> in there where it belongs. It also hides all the other categories. Second time you call the categories function it'll hide the main cat and wrap all other cats in <li></li> like you want. Finally you echo out a </ul> to close the unordered list.

Looks good on paper. Reckon you'll let us know if it works in the real world or not?

3 Feb 20, 2007 19:54

Works like charm. just had to add (') after the first <strong> tag

Thank you very much, just what I was looking for!

4 Feb 20, 2007 20:20

Cool. I edited my post above to include the corrective action you found.


Form is loading...