Recent Topics

1 Aug 12, 2006 00:33    

I'm running b2evo v 0.9.0.10. I know it's old. I plan to upgrade soon.

In multiblogs.php, how do I write a conditional that says "only show Blog B if there are posts in Blog B?"

Thanks for your help,
Glenn

2 Aug 14, 2006 17:58

Come on, somebody help a brother out. I know this has to be a simple if statement. I just don't know what to test it against.

The first blog shows this code

if( isset($MainList) ) $MainList->display_if_empty();	// Display message if no post

	if( isset($MainList) ) while( $Item = $MainList->get_item() )

But the following blogs don't show that code.

3 Aug 14, 2006 18:15

Well what do you want to display instead?

Are you talking about only displaying the blog in the blog list if there are posts in that blog?

And about your code attachment, keep looking for display_if_empty, it'll be there somewhere

4 Aug 14, 2006 18:26

I'm trying to setup an "Important Notices" Blog that appears above the regular "News" Blog. This "Important Notices" Blog will only show if there are posts in that blog. If there are no posts in the "Important Notices" Blog, then don't display any message or any Blog Title for the "Important Notices" Blog.

Any thoughts on how to achieve this?

Thanks for your help.

5 Aug 14, 2006 18:28

So if there are no important notices, you do not want the important notices blog to apear in the blog list, and if someone does access that blog, then [ redirect them back to the News blog or say there are not important notices atm ] ?

6 Aug 14, 2006 18:42

I will be using multiblog.php as my homepage. It will typical only show the "News" Blog unless an important notice has to be posted to the "Important Notices" Blog in which case the homepage will then display 1st the "Important Notices" Blog and then the "News" Blog directly below it.

When there are no important notices, I don't want show any part of the "Important Notices" Blog on the homepage. That includes any messages(like: There are no posts in this blog), or a Blog Title(like: Important Notices). I only want to show what is in the "News" Blog on the homepage.

So if there are no important notices, you do not want the important notices blog to apear in the blog list

- Correct

, and if someone does access that blog, then [ redirect them back to the News blog or say there are not important notices atm ] ?

- Not worried about that.

7 Aug 14, 2006 18:45

ok.

So how bout not having the 'Important Notices' blog shown in the blog list at all, and then always have the 'Important Notices' blog displayed above your 'News' blog. (without the display_if_empty for the 'Important Notices' blog).

Is this right?

We are nearly there ;)

8 Aug 14, 2006 18:54

If I did that, how would I keep the <h3>Important Notices</h3> from displaying all the time?

Seems like I would need an if statement that says:

IF
there are posts in "Import Notices" blog
then display the Blog Title (Important Notices)
then start a loop and display the important notices posts
then display the Blog Title (News)
then start a loop and display the news posts

ELSE
display the Blog Title (News)
start a loop and display the news posts
END IF.

9 Aug 14, 2006 19:15

Well my programming skillz only go out to the 1.8 and above versions of b2evolution.

But heres what you need to do.

Create a new Blog item by using the 'Important Notices' id, then stick this above your displaying of your 'News' blog.


if( isset($INotices) )
{  if( $INotices->number_of_posts > 0 )
   { echo 'your header';
     while( $Item = $MainList->get_item() )

Sorry i can't help more, hopefully another guru can get here which has experience with the 0.9 versions of b2evo.

10 Aug 14, 2006 19:46

I think we are on the right track. Unfortunately it didn't work. It didn't display anything.

Where could I find the equivalent of $number_of_posts variable?

Here is the code I tried:

<?php
		// Dirty trick until we get everything into objects:
		$saved_blog = $blog;
		$blog = 7;	// Blog B now
		
	?>
		
	<?php
		// You can restrict to specific categories by listing them in the two params below: '', array()
		// '', array(9,15) will restrict to cats 9 and 15
		// '9,15', array() will restrict to cats 9,15 and all their subcats
		$Notices = & new ItemList( $blog,	 $show_statuses, '', $m, $w, '', array(17), $author, $order, $orderby, $posts, '', '', '', '', '', '', '', '3', 'posts', $timestamp_min, $timestamp_max );
		if( $Notices->number_of_posts > 0 )
		{
			echo'your header';

			while( $Item = $Notices->get_item() )
			{
			?>
		
			<?php $Item->anchor(); ?>

			<h6><a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>">
			<?php $Item->title(); ?></a></h6>
			<div class="news">
				<?php $Item->content( 1, false ); ?>
				<?php link_pages() ?>
			</div>
			<?php
			}
		}
		?>

11 Aug 14, 2006 20:15

O.k. this seems to work

<?php
		// Dirty trick until we get everything into objects:
		$saved_blog = $blog;
		$blog = 7;	// Blog B now
				
		
	?>
		
	<?php
		
		// You can restrict to specific categories by listing them in the two params below: '', array()
		// '', array(9,15) will restrict to cats 9 and 15
		// '9,15', array() will restrict to cats 9,15 and all their subcats
		$Notices = & new ItemList( $blog,	 $show_statuses, '', $m, $w, '', array(17), $author, $order, $orderby, $posts, '', '', '', '', '', '', '', '3', 'posts', $timestamp_min, $timestamp_max );

		if( $Notices->result_num_rows > 0 )
		{
			echo'<div class="hr"><hr /></div><h3>IMPORTANT NOTICES</h3>';

			while( $Item = $Notices->get_item() )
			{
			?>
		
			<?php $Item->anchor(); ?>

			<h6><a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>">
			<?php $Item->title(); ?></a></h6>
			<div class="news">
				<?php $Item->content( 1, false ); ?>
				<?php link_pages() ?>
			</div>
			<?php
			}
		}
		?>

Notice the $Notices->result_num_rows. It seems to give the magic number.

Let me know if I shouldn't use that.

Thanks for your help,
Glenn

12 Aug 15, 2006 09:51

Yeh that is correct.

Glad you figured it out :)


Form is loading...