Recent Topics

1 Aug 13, 2006 05:10    

When I display blog #1 (All Blog), for each post, I want to display a link to that post's original blog. But I don't know how to get the post's original name/url when in the context of blog #1.

If I just do something like

<a href="<?php $Blog->disp( 'blogurl', 'raw' ) ?>"><?php echo $Blog->disp( 'name', 'htmlbody' ) ?></a>

the name/url it gives me is for blog #1, rather than for the blog in which the post was originally posted.

I know that I can get the numeric ID for the original blog by


$main_cat_is = $Item->get('main_cat_ID');
$blog_for_this_cat_is = get_catblog( $main_cat_is );

But once I have that numeric ID, I'm not sure what to call to get its name and URL so that I can construct the link.

Thanks in advance for any advice!

You can see this at

http://lakeshoreneighbors.org/blog/index.php/all

(The attribution to b2evo is in the footer of the page.)

2 Aug 16, 2006 14:21

http://doc.b2evolution.net/HEAD/evocore/Blog.html#methodBlog

So what you want to do is:


$blog_for_this_cat_is = new Blog ( $blog_for_this_cat_is );
echo 'The blog`s name is: '.$blog_for_this_cat_is->name;

The best way to find out wether the evocore can do something is to look at it :D I prefer just scanning all the files with dreamweaver till i find the method i want, but you may prefer the tech docs as they are more 'friendly

3 Aug 19, 2006 03:21

balupton wrote:

So what you want to do is:


$blog_for_this_cat_is = new Blog ( $blog_for_this_cat_is );
echo 'The blog`s name is: '.$blog_for_this_cat_is->name;

Thanks very much for the reply, and my apologies for the delay. (The notification of a reply was in my Spam box. I've fixed that now!)

When I do this, on the first post, the output I get is

The blog`s name is: New weblog

Every subsequent post has the output:

The blog`s name is:

The "new Blog" seems to be creating a new blog. What I'm looking for is information about the post's original blog (i.e., although the post is in blog #1, it really started out in blog #2 or #3, etc.).

Also, I think I failed to specify in my original question that I'm using version 0.9.0.12.

4 Aug 19, 2006 03:49

pipower wrote:

Also, I think I failed to specify in my original question that I'm using version 0.9.0.12.

That's plain old fashioned silly. Upgrade to at least 0.9.2 for so many reasons it's not worth going over.

As to your issue, dig on this: posts don't go in blogs - they go in cats and cats go in blogs. Now that you know this you can rework your efforts accordingly. Like first find the post's main cat ID then use that to find the associated blog's ID.

Hey try this. In the skin you use for your blog #1 add a bit of code to the post loop to tell you what b2evolution knows about the post.

			<?php if( is_logged_in() ) {
			echo '<pre>';
			print_r( $Item );
			echo '</pre>';
			} ?>


For the 0.9.* generation (may it rest in peace) you might have to print_r( $this ) instead $Item. Either way, scroll through and see if you have a value for blog_ID. You probably do, and for way back in the good old days I'm suspecting it'll be $this->blog_ID that will give up the correct blog number for ya.

After that I guess you'll want to turn it into a link to the blog, but that's something I'm sure you'll have fun doing and sharing with the rest of us.

5 Aug 19, 2006 04:03

EdB wrote:

That's plain old fashioned silly. Upgrade to at least 0.9.2 for so many reasons it's not worth going over.

Long story short: I have 0.9.0.12 because, at the time, I didn't realize I could install something newer than what cPanel gave me. So I wrote a ton of hacks, which work, and I have to launch on September 1. So I can't jeopardize it right now by installing a newer version and then trying to update my hacks. However, as soon as I launch, I'll work with a more-modern version on a parallel site and get everything ready.

EdB wrote:

As to your issue, dig on this: posts don't go in blogs - they go in cats and cats go in blogs. Now that you know this you can rework your efforts accordingly. Like first find the post's main cat ID then use that to find the associated blog's ID.

Hey try this. In the skin you use for your blog #1 add a bit of code to the post loop to tell you what b2evolution knows about the post.

			<?php if( is_logged_in() ) {
			echo '<pre>';
			print_r( $Item );
			echo '</pre>';
			} ?>


For the 0.9.* generation (may it rest in peace) you might have to print_r( $this ) instead $Item. Either way, scroll through and see if you have a value for blog_ID. You probably do, and for way back in the good old days I'm suspecting it'll be $this->blog_ID that will give up the correct blog number for ya.

Thanks! That was very informative. And, absolutely, I do get

[blog_ID] => 2

which is exactly the right blog.

So my question, then, is: how do I then get the title of the blog and its URL?

6 Aug 19, 2006 05:00

http://doc.b2evolution.net/ -> whatever version of b2evo you want -> click 'evocore' up the top -> click the class you want down the left side -> look for the function or variable you need.

7 Aug 19, 2006 18:49

Thanks to all for the pointers, suggestions,...

The following worked for me:


		$authors_blog = Blog_get_by_ID( $Item->blog_ID);
		echo '<div class="blog-title-link">';
			echo
				'<a href="',
				$authors_blog->disp( 'blogurl', 'raw' ),
				'" title="',
				$authors_blog->disp( 'shortdesc', 'htmlbody' ),
				'">',
				$authors_blog->disp( 'name', 'htmlbody' ),
				'</a>';
		echo '</div>';


Form is loading...