Recent Topics

1 Oct 02, 2007 18:59    

My b2evolution Version: 1.9.x

This is my very first post, so be gentle.

I have reviewed several other posts regarding the summary.php file and have been able to implement it fine. There is one thing that I wish I knew how to do.

I would really prefer to list the summary results ordered by date across all blogs, that is, in one list rather than separated by blog. It looks to me that this would require rewriting the following code in summary.php completely.


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

			while( $Item = $BlogBList->get_item() )
			{
			?>
			<li lang="<?php $Item->lang() ?>">
				<?php $Item->issue_date() ?>:
				<?php $Item->permanent_link( '#title#' ) ?>
				<span class="small">[<?php $Item->lang() ?>]</span>
			</li>
			<?php
			}
			?>
			<li><a href="<?php blog_list_iteminfo('blogurl', 'raw' ) ?>"><?php echo T_('More posts...') ?></a></li>
		</ul>
		<?php
	}
	// ---------------------------------- END OF BLOG LIST --------------------------------- ?>

My examination of this code tells me that the initial for loop here is stepping through each blog and outputting the summary info before moving to the next blog. That doesn't seem well suited to my purpose, so I'm trying to figure out how to best go about the task of ordering all posts, except for excluded blogs, by date and outputting the n most recent posts.

I'm still trying to figure out all of the available b2evo functions and elements at my disposal and how I might use them for this purpose. I've been thinking that I could do a direct database query to grab what I want, but thought that might be a crude and inelegant solution.

Any suggestions would be greatly appreciated.

Joel

2 Oct 03, 2007 02:22

I didn't test, so that part is up to you. ;)

Try editing this line of code (issue_date):

$BlogBList = & new ItemList( $blog,  '', '', '', '', '', array(), '', 'DESC',
'issue_date', 3, '', '', '', '', '', '', '', 'posts' );

You find the (technical) doc for this line of code [url=http://doc.b2evolution.net/v-1-9/evocore/ItemList.html#methodItemList]here[/url] (version 1.9), which ables you to toy with it even more.

Good luck

3 Oct 04, 2007 03:13

Thanks for the tip, Afwas. I had started looking there and it is nice to be told I'm at least looking in the right spot. :D

Here's what I ended up with. It was actually much easier than I had expected. I just removed the for loop and then listed the posts from my blog all ($blog = 1).


<ul>
<?php // --------------------------- BLOG LIST -----------------------------
	$blog = 1;
	$BlogBList = & new ItemList( $blog,  '', '', '', '', '', array(), '', 'DESC', '', '', '', '', '', '', '', '', '', 'posts' );
	while( $Item = $BlogBList->get_item() ) {
		?>
		<li lang="<?php $Item->lang() ?>">
		<?php $Item->issue_date() ?>:
		<?php $Item->permanent_link( '#title#' ) ?>
		<span class="small">[<?php $Item->lang() ?>]</span>
		</li>
		<?php
		}
// ---------------------------------- END OF BLOG LIST --------------------------------- ?>
</ul>

This works fine, but it will only display the number of posts that you have set to be displayed in Admin under App Settings. I also wrote a funky bit of code that would allow me to ignore some blogs which I didn't want included in the list. I'm sure someone else could come up with something prettier, but this is what I did.


<ul>
<?php // --------------------------- BLOG LIST -----------------------------
	$blog = 1;
	$BlogBList = & new ItemList( $blog,  '', '', '', '', '', array(), '', 'DESC', '', '', '', '', '', '', '', '', '', 'posts' );
	while( $Item = $BlogBList->get_item() ) {

// Insert lines below to keep some blogs from being included in the list.
		$Item->get_creator_User();
		if( $Item->assigned_user_ID ) {
			$the_author = $UserCache->get_by_ID( $Item->assigned_user_ID );
 			} else {
			$the_author = $Item->Author;
			}
		$who = $the_author->get_preferred_name();
		$left_out = array( "username1", "username2", "username3", "etc..." );
		if ( in_array( $who, $left_out ) ) {*/
// Insert lines above to keep some blogs from being included in the list.

			?>
			<li lang="<?php $Item->lang() ?>">
			<?php $Item->issue_date() ?>:
			<?php $Item->permanent_link( '#title#' ) ?>
			<span class="small">[<?php $Item->lang() ?>]</span>
			</li>
			<?php
			}
		}
// ---------------------------------- END OF BLOG LIST --------------------------------- ?>
</ul>

[/php]


Form is loading...