Recent Topics

1 Jan 18, 2008 08:24    

Hello

I am working with the file 'posts.main.php' file in the evocamp skin (b2evolution 2.3).

I am triying to addapt the way the list of the posts is showed (making a filter of the posts). I am making modifications inside the loop 'while( $Item = & mainlist_get_item() ) {... ' where I want to get acces to the categorie of the post, to the tags of the post, to the extra fields of the post... I kown that $Item->get('title') gives me the tittle of the post. How can I get acces to the other variables like category, subcatecogie, tag? How can I make particular filters here?

while( $Item = & mainlist_get_item() {
if ($Item->get('maincategorie')=="categoria1"){ .... ????????

Many thanks

2 Jan 22, 2008 04:41

One thing that might work for you is to add a bit of code to get all the categories. Something like this MIGHT work:

			<?php
				$These_Cats = $Item->categories( array(
						'before'          => ' | '.T_('In '),
						'after'           => ' ',
						'include_main'    => true,
						'include_other'   => true,
						'include_external'=> true,
						'link_categories' => false,
						'format' => raw,
					) );
			?>

Then to see what info you now have to work with you would want to echo it privately to you. I suspect you'll have an array returned, so try this right before the closing ?> line:

if( $is_logged_in() ) {
echo '<pre>';
print_r( $These_Cats );
echo '</pre>';


After you know that it is an array and what type of info will be in the array you can use PHP's [url=http://us.php.net/manual/en/function.in-array.php]in_array[/url] function to basically say "if this cat is in the array then do something".

This is COMPLETELY untested, but is what I would do if I was trying to do what you want to do. Best of luck with it!!!


Form is loading...