Recent Topics

1 Jun 04, 2006 11:39    

Hey all,

My first post - yippee!

Apologies if this has been explained somewhere...

I'd like to have a home page (which is not the blog's home page - the blog is in a separate page in a subdir from the home page) display the titles of the last three posts of the blog as a 'what's new' section. Clicking them would obviously go to that post.

Is there a query that I can use to insert the three newest titles (from all categories) on a home page?

I hope that makes sense...

Thanks for any info.

_Bhaal

2 Jun 05, 2006 10:19

OK, I found the answer: the code I need is in summary.php (thanks mr. b2 author for including this file!).

The code is here:


<?php // --------------------------- BLOG LIST -----------------------------
	for( $blog=blog_list_start('stub');
				$blog!=false;
				 $blog=blog_list_next('stub') )
	{ # 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() ?>:
				<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>"><?php $Item->title( '', '', false ); ?></a>
				<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 --------------------------------- ?>

One more question:

Is there an easy way to truncate the post title that is displayed in the code above to just 30 characters - followed by '...' if there are more than 30 chars in the title?

I know that substr() function can truncate a database entry, so it would be something like this:


$MyDesc = substr($a1[Desc], 0, 30)."...";

But I've tried it and it didn't work.

Any help would be greatly appreciated.

3 Jun 06, 2006 10:30

echo substr( $Item->title, 0, 30 ).'...'; ;)

¥

4 Jun 06, 2006 19:07

Thank you ¥åßßå!!!

It works!


Form is loading...