Recent Topics

1 Sep 15, 2008 01:08    

My b2evolution Version: 2.x

Given a list of blog ids can any one tell me if there are any helper functions to produce a list of blog url links?
Do I have to load the contents of the whole blog to get the title or is there a better way?

Thanks.

2 Sep 15, 2008 03:35

I think this is the fastest way. Put this function in conf/_config_TEST.php (create new file)

function get_blog_urls( $IDs )
{
	$BlogCache = & get_Cache( 'BlogCache' );
	$blogs = explode( ',', $IDs );
	$r = array();
	foreach( $blogs as $blog )
	{		
		if( $Blog = & $BlogCache->get_by_ID( $blog, false, false ) )
			$r[$blog] = $Blog->gen_blogurl();
	}
	return $r;
}

to display the blog url use

$urls = get_blog_urls('2,8,9');
echo $urls['8'];

3 Sep 16, 2008 13:38

Are the blog ids the ones from the database table evo_items__item.post_ID?
Each time I call get_by_ID I get a return of false.

4 Sep 16, 2008 14:29

No. That's the post ID. The blog IDs can be found in the table evo_blogs.
Do you want to get the URL of the blog a post belongs to?

5 Sep 16, 2008 17:21

Sorry, I think I have made a technological cock-up.
I think I should re-word the original question to:

Given a list of post ids can anyone tell me if there are any helper functions to produce a list of post url links?
Do I have to load the contents of the whole post to get the title or is there a better way?

I have an id for a post and I want the post (article) url, the one in the form:
http://www.bigsoft.co.uk/blog/index.php/2008/09/09/simple-xsl-xslt-example
with the associated title of "Simple XSL / XSLT Example", bearing in mind that the format of the post article may change depending on the blog/global settings

Sorry for my misunderstanding. Can you help with this instead ?

6 Sep 16, 2008 17:50

Freetyped ... so expect errors ;)

<?php
$foo = get_Cache('ItemCache' );
$post_IDs = array( 1,3,5,7,9 );
foreach( $post_IDs as $bar )
{
  $Item = $foo->get_by_ID( $bar );
  // do whatever with all $Item abilities here
}

¥


Form is loading...