Recent Topics

1 Sep 24, 2005 08:21    

Is there a way to show the recent posts from all the blogs in the sidebar, but without using BlogAll? I'd like something like to be able to show something like this:

RECENT POSTS

NAME OF BLOG 2

date title of post 1 as permalink
date title of post 2 as permalink
date title of post 3 as permalink
date title of post 4 as permalink
date title of post 5 as permalink

NAME OF BLOG 3

date title of post 1 as permalink
date title of post 2 as permalink
date title of post 3 as permalink
date title of post 4 as permalink
date title of post 5 as permalink

NAME OF BLOG 4

etc, etc...

Is this possible?

jj.

2 Sep 24, 2005 17:32

Take a look at the code in summary.php. That's basically what it does. You should be able to pull the relevant code and stick it in your sidebar.

3 Sep 24, 2005 20:14

I had started to look at that code, and tested it by replacing my existing "Recent Posts" block with the one from summary.php. It appears to display the recent posts properly, but then it bombs on the next code block, which is the "Archives"...

So... it shows the 5 most recent posts from each blog, then it shows the title for the next block "Archives", and then shows this error:

Archives

MySQL error!

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND bloguser_user_ID = 1' at line 4(Errno=1064)

Your query:
SELECT * FROM evo_blogusers WHERE bloguser_blog_ID = AND bloguser_user_ID = 1

As soon as I replace the recent posts block in _main.php with the original one I was using, the error disappears.

This is the code I'm using for the two sections in question:

<!-- ============== RECENT POSTS =============== -->
<!-- =========== START SIDEITEM 3 ============ -->

<div class="bSideItem">
	<h3 class="sideItemTitle"><?php echo T_('Recently Posted') ?></h3>
<ul id="recentpost">
<?php // --------------------------- BLOG LIST -----------------------------
	for( $blog=blog_list_start('stub');
				$blog!=false;
				 $blog=blog_list_next('stub') )
	{ # by uncommenting the following lines you can hide some blogs
		if( $blog == 1 ) continue; // Hide blog 1...
		?>
<h4><a href="<?php blog_list_iteminfo('blogurl', 'raw' ) ?>" title="<?php blog_list_iteminfo( 'shortdesc', 'htmlattr'); ?>"><?php blog_list_iteminfo( 'name', 'htmlbody'); ?></a></h4>
		<?php	// Get the 5 last posts for each blog:
			$BlogBList = & new ItemList( $blog,  '', '', '', '', '', array(), '', 'DESC', '', '', '', '', '', '', '', '', '', '5', 'posts' );

			while( $Item = $BlogBList->get_item() )
			{
			?>
			<li lang="<?php $Item->lang() ?>">
				<?php $Item->issue_date() ?>
				<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>"><?php $Item->title( '', '', false ); ?></a>

				<span class="small"> <!-- [<?php $Item->lang() ?>] --> </span>
			</li>
			<?php } ?>
			<li><a href="<?php blog_list_iteminfo('blogurl', 'raw' ) ?>" title="<?php echo T_('more...') ?>"><?php echo T_('<br />More posts...') ?></a></li>

<?php } ?>
</ul>
</div>





<!-- ============ END SIDEITEM 3 ============= -->


<!-- ============== ARCHIVES ============== -->
<!-- =========== START SIDEITEM 4 ============ -->

<div class="bSideItem">
<h3><?php echo T_('Archives') ?></h3>
<ul>
<?php // ARCHIVES INCLUDED HERE
require( dirname(__FILE__).'/_archives.php' ); ?>
<li><a href="<?php $Blog->disp( 'arcdirurl', 'raw' ) ?>" title="Visit the complete archives"><?php echo T_('more...') ?></a></li>
</ul>
</div>

jj.

4 Sep 25, 2005 00:18

This is just a guess, but try putting this before the code from summary.php:

<?php
// Dirty trick until we get everything into objects:
$saved_blog = $blog;
 ?>


And this after the summary.php code:

<?php
// Restore after dirty trick:
$blog = $saved_blog;
?>


Let me know if that makes a difference.

5 Sep 25, 2005 03:07

Yeah, that did the trick! Thanks!

What is it about that code without the top and bottom piece that caused the problem? It seems weird to me that the problem wasn't even in that piece of code, but that it caused a problem in the next piece of code after it. Strange.

jj.

6 Sep 25, 2005 03:18

I can answer that! The snippet you used to create your recent posts bit in your sidebar actually changed the value of a very important variable. By using the old fashioned "dirty trick" you first save what that variable is supposed to be, then reset it to it's original value after you're done fiddling with it. If you don't 'remember and recall' the important variable you get stuck with it's modified value. Without the dirty trick archives was trying to deal with $blog but couldn't quite handle it. The dirty trick and restoration effectively said "for a little while we're going to have to work with $blog in a different sort of way so let's hang on to what it was so that archives can do it's thing later on".

Slick eh?


Form is loading...