Recent Topics

1 Nov 03, 2005 12:54    

I'm using the summary.php page to show blog posts from the bloggers in my community. I've gotten it down to 1 blog post from each blogger in the community so far. My question is, how do I make it so that there are a maximum of 5 blog posts from the most recently updated blogs and not the entire community? Because the problem is, some of my bloggers haven't updated their blogs and the same topics appear over and over. Each additional blogger (that's added to the community) their topics are adding to what's showing on the front of the site, UNDERNEATH the old blog posts. I am just trying to find a way to automate the new blog posts to the front of the site while it kicks off the older postings. Is there another file that can do that or is there something I can do to the summary file to make it do this?

2 Nov 03, 2005 15:04

Blog 1, also called Blog All, is a special aggregator blog that does just that. It shows the latest x post from accross your whole installation (where x is a number you can specify.)

3 Nov 03, 2005 18:23

Ok, I've been looking at the Blog All file, I made a seperate duplicate file. I know there's something in here:

if( empty($blog) )
{	// No blog requested, by URL param, let's check extrapath
  # echo 'Checking extra path...<br />';
	// Check and Remove current page url:
	$index_url = substr( $baseurl, strlen( $baseurlroot ) ) . '/index.php';
  # echo 'Seeking ['.$index_url.'] in ['.$ReqPath.']...<br />';
	if( ($pos = strpos( $ReqPath, $index_url )) !== false )
	{ // note: $pos will typically be 0
    # echo 'Matched index.php path...<br />';
		$path_string = substr( $ReqPath, $pos+strlen( $index_url ) );
		// echo "path=$path_string <br>";
		$path_elements = explode( '/', $path_string, 20 );						// slice it
		if( isset($path_elements[1]) && (($Blog = $BlogCache->get_by_stub( $path_elements[1], false )) !== false) )
		{	// We found a matching blog:
			$blog = $Blog->ID;
		}
	}
}

if( empty($blog) )
{	// Still no blog requested,
	$blog = $Settings->get('default_blog_ID');
}

if( empty($blog) )
{	// No specific blog to be displayed:
	// we are going to display the default page:
	require dirname(__FILE__).'/default.php';
	exit();
}

That I need to change, but I don't get it. I just want the url titles and not the whole posts. Is that possible from what I'm seeing here? And can I only use 1 post from each blog that's been updated? Sometimes my bloggers (poets) post multiple poems to their pages at once, I don't want the entire section that I'm showing to be of one poet's work.

4 Nov 03, 2005 20:43

What is it that you want again? You want a whole page that just shows the 5 most recent posts from accross all your blogs, and just titles? Do you want this on a page by itself, or are you including it in another page. The code you listed decides what blog is displayed, not how it is displayed. That is done in a skin (or a template, which is like a combination of a stubfile and a skin).

You'll have to decide whether you want the x most recent posts from the whole site, or each blog's y most recent posts. Or you could do both, in seperate parts of the page. I don't see any way to combine them in one list, though.

Let me know what you want and I'll help you get there.

5 Nov 03, 2005 22:28

This is what I have done. Say www.frontofthesite.com is my site, On that page, I have basically created a section that is similar to a forum in that I want it to be "The Most Recently Updated Blogs"(instead of posts in a forum). Right now the Summary file is doing fine because there isn't a huge outpouring of blogging going on as the site has just started...however, I have noticed that the older posts are on top, and aren't being moved off the page once newer posts have been entered in other blogs(I have used a php include to bring the summary file into this page). Therefore I am concluding that the posts will just keep growing in length as more people are added to the blogging community. I just want the latest 5 posts from throughout the blogging community to aggregate to the front of the site.

Once that is resolved, I don't want one blog to fill up all 5 spots on the "Most Recently Updated" section, because I have bloggers that will put in 6-7 entries at once. That blog should only get one link. How is it that I can assure that or is there no way to do that? Right now, the summary file does handle this part of things admirably.

Thank you in advance Personman, you are being extremely helpful :)

6 Nov 03, 2005 22:36

I don't see an easy way to do that. You may have to choose one or the other. I'm sure it's possible to do just what you're describing, but it would be a big job. Summary and Blog All are ready-made solutions. I know they don't do it quite how you would like, but what you're asking for goes beyond my skill. You could put it in as a [url=http://forums.b2evolution.net//viewforum.php?f=8]feature request[/url] or a [url=http://forums.b2evolution.net//viewforum.php?f=34]hack request[/url] and see what happens.

7 Nov 03, 2005 23:31

Ok, I'll choose the blog all. It seems to only allow 5 posts before it switches over to a new page (which is still good). So, how do I just use it to get the link titles and not the posts?

*Meanwhile I will ask 4 a feature request or hack* but the answer for this will do nicely for now....

8 Nov 03, 2005 23:40

If you have 1 author per blog, then I think you could do this with a modified skin on Blog 1 (the agregator).

What you would need to do is add some code to the _main.php file to create an array of author IDs (empty to begin with). As it renders each post, it should check the author ID of the post and make sure it's not in the array. If it is not in the array, then it renders the post and adds the author ID to the array. If it is in the array, then it skips the post (put the rendering code in an IF statement).

You will also probably have to set the Blog 1 display to a high number of posts (like maybe 25), and then manually count the posts you render and stop them at whatever number you want to display (5).

The end result should be that it fetches the last 25 (or whatever number) posts from all blogs, and then displays one post from each author until it reaches your set number. That way, you get one post from each of the last updated blogs (up to 5).

Sorry I don't have any code examples - this is just off the top of my head. If you can't figure it out, I might be able to help you with it later.

BTW - in the _main.php file for your skin, you can also edit the code to make it display only the title and permalink, without the post content.

9 Nov 04, 2005 07:14

yes I have one author per blog, I am able to edit code, but I'm not able to write code like that, lol. I'll wait until you can help me but I know I can edit the _main.php file in the meantime to display only the title and permalink. Can you help me with the other part? The rendering of posts and checking the author id?

10 Nov 04, 2005 17:15

This should work. I was able to just use blog IDs, so you don't have to worry about authors (I was afraid the posts would all return a blog ID of 1, since you are using the agregator blog, but that's not the case - they return the actual blog they belong to).

I'm using the "Custom" skin, so you may have to adjust slightly if you are using a different skin.

Find the following lines:

<?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->date_if_changed();

And modify them to look like this:

<?php // ------------------------------------ START OF POSTS ----------------------------------------
   if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post

//------- Set up array to keep track of blogs used.
$blogsUsed = array(1);

//------- Set the max number of posts to display, and create a counter to keep track.
$displayMax = 5;
$displayCounter = 0;

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

//------- Search for the blog in the array.  If it's not there, add it to the array, increment the counter, and display the post.
$currentBlog = $Item->blog_ID;
if ((array_search($currentBlog, $blogsUsed) == false) && ($displayCounter < $displayMax)) {
$blogsUsed[] = $currentBlog;
$displayCounter++;

      $MainList->date_if_changed();

Change the $displayMax variable to the number of posts you want displayed.

Then find the following line (farther down):

<?php } // ---------------------------------- END OF POSTS ------------------------------------ ?>


And add a bracket, so it looks like this:

<?php }} // ---------------------------------- END OF POSTS ------------------------------------ ?>

Just remember that you need to set the number of posts per page in the backoffice to a high number to make sure it gets enough posts to find one for each blog. This might only need to be 10 or 15, but it might need to be 20 or 30. It depends on how frequently some of your bloggers post. If you set it too high, though, you are going to take a performance hit for looping through more posts than you need.

Also remember that if you use this skin on a blog other than the agregator (blog 1), then you are going to get strange results (it will only show one post per page, and clicking "next" will skip a bunch of posts). You will probably get strange results if you try to use the calendar or archive links as well.

11 Nov 05, 2005 19:01

Ok, I think I did get some weird results. Let me explain better.

There is my site. As you can see on the main page, I have virtual pen. That is where the blog titles are being aggregated. I'm using the summary file for that. I changed skins, and am using my clean skin applying the changes that you recommended and I applied it to the summary file because I don't want to change the index file (I like that the way it is).

Right now the blogs that are accrued in the virtual pen space are in order of the blog numbers, rather than who posted last from the virtual pen community. Is there a way to do that using the changes that you just gave me? Because I am just not getting this...changing the skin did nothing to change what's aggregating to the front of the site. Was it supposed to?

12 Nov 05, 2005 19:32

Maybe it's me misunderstanding things, but blog all appears to do what you want without any changes ?

Create a stub file (see a_stub.php in your root directory) set :-
$blog = 1;
$posts = ##; // set ## to the number of posts you want per page
$skin = 'fred'; // or any name you choose

Then, copy a skin and call it fred (or whatever name you chose) and strip the fred/_main.php down to what you want.

¥

13 Nov 05, 2005 20:28

That does seem accurate. I will see if it works for me. Thanks Yabba

14 Nov 05, 2005 23:27

Sorry if I wasn't clear, but I was suggesting that you not use the summary.php file at all, and instead use the agregator blog (blog 1) with a skin that is modified as I described. I guess that a stub file would be the best way to do that, as ¥åßßå suggested.

¥åßßå - the thing that is different about what caramelkissed has asked for (and the purpose of my code above) is to make Blog 1 only show the latest (1) post from each blog. So if the 4 latest posts are from the same blog, then only show one of those. Basically, it's a list of "the latest post from each of the most recently updated blogs".

That is, unless I misunderstood.

15 Nov 05, 2005 23:43

No you are accurate, Kweb. That IS what I want. I ended up using the a_noskin blog with the 1 setting for the main aggregator blog, but adding a skin was too much trouble and after toiling with this for 4 hours just to get it to work correctly, I am realli tired, lol.

16 Nov 05, 2005 23:48

The reason I didn't use the main blog to make the changes was because I did not want to change that blog. I want it the way it is now. I applied blog 1 to the a_noskin blog and it does aggregate the blogs the way I want but I have 2 posts from the same user in there, which is not what I wanted to happen. My poets will post 4 and 5 poems at one time so there is a likelihood that their poems will be the only poems aggregating to the front of the site. I don't want that. So is there a way I can apply the information you recommended, Kweb to the a_noskin blog?

17 Nov 06, 2005 02:04

I believe it should work the same way. The code in the a_noskin.php file is very similar to the _main.php file in the custom skin, so you should be able to make the same modifications to the a_noskin.php file and get the same results that way. I would recommend making a copy of the file, and making your changes there, so that you don't confuse it with the original and so that future upgrades don't overwrite it. You should be able to name it whatever you want.


Form is loading...