Recent Topics

1 Apr 21, 2007 05:45    

My b2evolution Version: 1.9.x

Hello.

I recently installed b2evolution to my website and it is working just fine. My blog is going to be used for content updating reasons for my personal website. Therefore, I want my viewers to be able to read the posts from my main index page of my website, where the rest of my content is.

My question is: How do I get my recent posts to appear on my index page in a manner where my viewers won't have to go to my b2evolution blog page to actually read my posts?

2 Apr 22, 2007 00:35

I have a similar situation. I want to place a recent posts list on my main website pages on the side column so people visiting my site will see I also run a blog on the topics.

I have searched through the forum and plugins and such but have only found the code used in a new template construction and not any info on what files would have to be included into another page to make the code operate properly for just a recent posts listing.

3 Apr 22, 2007 00:42

incidently here is the code I found so far:

<div class="bSideItem">
	<?php $BlogBList = & new ItemList( 4,  '', '', '', '', '', array(), '', 'DESC', '', 1, '', '', '', '', '', '', '', 'posts' );
	while( $Item = $BlogBList->get_item() )	{ ?>
	<strong><?php $Item->permanent_link('#title#'); ?></strong>
	<div style="cursor:pointer" onclick='window.location="<?php echo $Item->get_permanent_url(); ?>"'>
		<?php $Item->content(1,false,'#','#','#','#','htmlattr'); ?>
	</div>	
	<?php }  ?>		
</div>

Just at a glance I can see this needs the $BlogBList definition, and the $Item definition.

I have looked in some of the php files but from a programming standpoint find the flow a little difficult to follow. I am continuing my efforts however while hoping someone here will know more and eventually speak up.

4 Apr 22, 2007 01:32

I am still working out all the details but apparently a solution to this problem is to use the rss feed and a simple php rss parser like magpie to insert a recent blog listing on another webpage outside of the blog site itself.

5 Apr 22, 2007 04:41

rjehall wrote:

Just at a glance I can see this needs the $BlogBList definition, and the $Item definition.

And the $BlogBList and the $Item variable depend on a few other variables from a few other files. This way all the files you once uploaded are connected to each other file (mostly through include statements).
rjehall wrote:

I am still working out all the details but apparently a solution to this problem is to use the rss feed and a simple php rss parser like magpie to insert a recent blog listing on another webpage outside of the blog site itself.

You're getting warm now. If I let you, you'll find the solution yourself. But I give you a hint:
The RSS is nothing more than a skin. You can customize a skin any way you want. Consider a skin with noting on it. This is the "basic" skin with no <body> contents:

<?php
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

skin_content_header();	// Sets charset!
?>
<html>
<head>
	<?php skin_content_meta(); /* Charset for static pages */ ?>
	<?php $Plugins->trigger_event( 'SkinBeginHtmlHead' ); ?>
	<title><?php
		$Blog->disp('name', 'htmlhead');
		request_title( ' - ', '', ' - ', 'htmlhead' );
	?>
	</title>
	<?php skin_base_tag(); /* Base URL for this skin. You need this to fix relative links! */ ?>
	<meta name="generator" content="b2evolution <?php echo $app_version ?>" /> <!-- Please leave this for stats -->
	<?php
		$Blog->disp( 'blog_css', 'raw');
		$Blog->disp( 'user_css', 'raw');
	?>
</head>
<body>

</body>
</html>


In the body you can enter this piece of code:

<?php 
     $TOPART = new ItemList($blog, array(), '', '', -1, '', array(), '', 'DESC', 'views', 5); 
     echo "<ul>"; 
     while ($TOPART_ITEM = $TOPART->get_item()) { 
     echo "<li><a href=\"", $TOPART_ITEM->get_permanent_url(); 
     echo "\">", $TOPART_ITEM->title('','',false), "</a>"; 
     } 
     echo "</ul>"; 
 ?> 


It displays the titles of the five most recent posts.
Save this file as _main.php in a NEW folder in the ../blogs/skins directory of your blog. You've just created a new skin.
You can call the blog with the new skin -change it to match your blog's url:
h ttp: // w w w.yoursite.com/blogs/all_stub.php/?skin=new

That should work. In your main website's page you can make an iframe in the sidebar. In this iframe you can call the ultra minimal skin with the url as above.

You can make variations on this theme. If you copy and rename the folder _rss, you can experiment with an edited rss file. Try calling this file through: h ttp: // w w w.yoursite.com/blogs/all_stub.php/?skin=_rss_renamed

good luck

6 Apr 22, 2007 05:18

That sounds like a good way to do it. I managed to work it out using the magpie rss reader in the following way:

	 // Magpie rss feed
	 require_once($p4it_root_path.'includes/rss_fetch.inc');
	 define('MAGPIE_CACHE_DIR', $p4it_root_path.'rsscache');
	 $rss = fetch_rss( 'http://prepare4it.net/blog/index.php/?tempskin=_rdf' );
	$channel = $rss->channel['title'];
	$num_items = 5;
	if (isset($rss->items))
	{
	$items = array_slice($rss->items, 0, $num_items);
	foreach ($items as $item) {
	 	//Using the PHPBB Template System to assign variables to the template
		$template->assign_block_vars('blogfeed', array(
		'link' => $item['link'],
		'item' => $item['title'])
		);
		}
	}
	
	// End Magpie

of course later I threw the $channel variable into the main assign_vars statement for the template.

Those familiar with PHPBB templates should enjoy this second solution. As well this method doesnt need the iframes.

At the very least its nice to have a couple ways to make this happen.

Anyone else have another method they'd like to share?

7 Apr 22, 2007 08:04

So what code would I need to use if I wanted the five most recent posts themselves, instead of post titles? And how would I go about setting it all up?

You'll have to forgive me, but you'll have to be very plain and descriptive with me, I am not all that familiar with this advanced of code.

8 Apr 22, 2007 16:59

If you want the five most recent posts, that's going to be quit a chunk if you want it in the sidebar of another site.
But it's easy.
Have a look at the original _main.php file of the basic skin. First have a look at the skin in action, like calling it in the browser: h ttp: // w w w.yoursite.com/blogs/all_stub.php/?skin=basic.
You'll notice it isn't much, but still it's too much. If you have a look at the _main.php file, you'll notice some chunks of code that correspond to particular pieces in the blog, like:

<?php
	/**
	 * --------------------------- BLOG LIST INCLUDED HERE -----------------------------
	 */
	require( dirname(__FILE__).'/_bloglist.php' );
	// ---------------------------------- END OF BLOG LIST --------------------------------- ?>


corresponds to the list of all available blogs. You can delete it.

	<?php // ------------------------------- START OF SKIN LIST -------------------------------
	if( ! $Blog->get('force_skin') )
	{	// Skin switching is allowed for this blog:
		echo T_( 'Select skin:' ), ' ';
		for( skin_list_start(); skin_list_next(); )
		{ ?>
		[<a href="<?php skin_change_url() ?>"><?php skin_list_iteminfo( 'name', 'htmlbody' ) ?></a>]
		<?php
		}
	} // ------------------------------ END OF SKIN LIST ------------------------------ ?>


corresponds to the list of all available skins, you can delete it.
You are only interested in the part that starts with:

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

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


And even in this chunk of code there are lines you can do without (date, author, permalink)
Delete those lines and you end up with plain text with the title and the post itself.
Done that, you can incorporate this in another site preferrably through an iframe (search Google for that).

Did I mention you should copy and rename the ../blogs/skins/basic folder before you start editing the _main.php file? That way you create a new skin.

Good luck

9 Apr 22, 2007 22:05

I thought of one more thing that can help you: If you add a css file to your blog, you can disable certain features through the "display:none" command, like the images in your post:

img{
display: none;
}


You can even make a summary (the first paragraph for example). You could make a <div> for this summary and don't display it in the real blog and do display it in the mini blog for the other site.


Form is loading...