Recent Topics

1 Apr 09, 2007 04:41    

My b2evolution Version: 1.9.x

Whats the cleanest way to only show $Item->categories(); on the Index page and not on category pages.
My _main.php is as follows..
The section I'm talking about is at the end within the <p class="time"> tags

<?php
	// ------------------------------------ START OF POSTS ----------------------------------------
      if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post
      if( isset($MainList) ) while( $Item = & $MainList->get_item() )
	
	{
		$MainList;
	?>
      <div class="bPost bPost<?php $Item->status( 'raw' ) ?>" lang="<?php $Item->lang() ?>">
 
   				<?php
			locale_temp_switch( $Item->locale ); // Temporarily switch to post locale
			$Item->anchor(); // Anchor for permalinks to refer to
		?>
<?php
echo '<p class="center">';
next_post( '&lt;- %&nbsp;&nbsp;', '', 'yes'  );
previous_post( '&nbsp;&nbsp;% -&gt;', '', 'yes' );
echo '</p>'; ?>

<!-- google_ad_section_start -->
	<h2>&nbsp;<a href="<?php $Item->permanent_url() ?>" rel="bookmark" title="<?php echo T_('Permanent link to ...') ?><?php $Item->title(); ?>"><?php $Item->title(); ?></a></h2>
<p class="time"><?php
			$Item->issue_date('d F y');
			echo '&nbsp;&nbsp;&nbsp;';
			$Item->categories();
			?>
</p>

2 Apr 09, 2007 04:47

Check the value of $disp.

e.g.

if ($disp == 'home') {
 ....  Your code ...
}

If it doesn't work, make sure you declare it using global near the top of your template.

global $disp;

3 Apr 11, 2007 11:01

<?php
if( !empty( $cat ) )
{
echo '<p class="time">';
            $Item->issue_date('d F y');
            echo '&nbsp;&nbsp;&nbsp;';
            $Item->categories();
echo '</p> ';
}
?>

You never know, it might work :roll:

¥

4 Apr 11, 2007 11:41

At Yabba
Yep, it works but I want it in reverse :)
I want the $Item->categories() to show on the home (index.php) page and not on Categorie pages....

5 Apr 11, 2007 13:18

My logic for this is that if you have selected a category from the menu, you don't need it's name repeated over and over while your in that category.
On the other hand, the index page could have 5 posts from 5 different categories so it's worth linking to it within each post.

Here's what I hacked together
Ok, if there is a cleaner way I'm all for it...

<?php
if( !empty( $cat ) )
{
echo '<p class="time">';
            $Item->issue_date('d F y');
            echo '</p> ';
} else {
echo '<p class="time">';
            $Item->issue_date('d F y');
            echo '&nbsp;&nbsp;&nbsp;';
            $Item->categories();
echo '</p> ';
}
?>

Thanks for the help ¥åßßå and smpdawg

6 Apr 11, 2007 13:24

<?php
echo '<p class="time">';
$Item->issue_date('d F y');
if( empty( $cat ) )
{
      echo '&nbsp;&nbsp;&nbsp;';
      $Item->categories();
}
echo '</p> ';
?>

Oops, there was an extraneous ! in there :roll:

¥


Form is loading...