Recent Topics

1 Mar 03, 2006 08:24    

Hi all.

New to this forum and blog, so many thanks to all you tireless guys for your hard work; You are true gentlemen.

I have a very basic question, to which I have not been able to find an answer.

I wish to create a blog on my site, which is no problem, but I also want to add a small cell to a table on the sites front (www.sitename.com/index.htm or index.php) page which displays a section of the most recent post (upto 100 words / characters) and a link to the blog. I guess I need a way to have php lift the latest comments from the mysql data base, but I have no php or mysql skills, and I am therefore somewhat out of my depth.

Any help would be very, very much appreciated.

Thanks. Anthony.
:D

2 Mar 03, 2006 12:08

Mmmmh seems pretty easy since you just have to use b2evo's engine...

I think the smartest solution is using a stub file that you will include in your website's index.php.
A stub file is a file that let you show your blog and bypas some options such as skin, # of posts displayed, their order...

Here is a sample that may be useful (save this as stubfile.php in b2evo's install folder):


<?php
$blog = 4;   	// Your blog's number: see it in admin page
$timestamp_max = 'now'; //don't display future posts (you may have edited publication's date)
$posts= 1; //show 1 post only
$skin="noformatting"; //let u use another skin
require(dirname(__FILE__)."/b2evocore/_blog_main.php"); //let's go !!
?>

You should also build a skin without title, categories, etc: could be a simple _main.php looking like that:

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

	if( isset($MainList) ) while( $Item = $MainList->get_item() )
	{
		$MainList->date_if_changed();
		$Item->anchor(); 
		locale_temp_switch( $Item->locale ); // Temporarily switch to post locale
		?>
		<h3>
			<?php $Item->issue_time(); ?>
			<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>"><img src="img/icon_minipost.gif" alt="Permalink" width="12" height="9" border="0" align="middle" /></a>
			<?php $Item->title(); ?>
		</h3>

		<blockquote>


		
			<div>
				<?php $Item->content( '#', '#', T_('Read more...') ); ?>
				<?php link_pages() ?>
			</div>

		</blockquote>
	<?php } ?>

In this example you should name it skins/noformatting/_main.php and call your post with:

include(b2evoinstalldir/stubfile.php); 

Yous can customize the _main.php to show number of comments, etc (see in your skin folder)...

To limit the # of characters displayed you can either use the more button in edition form of the backoffice, or use a php function that will handle the job only for the index.php page: this is called word wrapping, I don't have the code here (the difficult part is not breaking the text in the middle of an html tag: see http://www.php.net/wordwrap for help)

Hope this helps ;)

3 Mar 29, 2006 16:44

Thanks. This was very helpful to me.

4 Apr 09, 2006 19:30

So, this being one of my first attempts at fiddlin' with the code
I naturally have a couple dumb questions.

http://fredsitelive.com/blogs/

I'm using ver. 1.6 Alpha. Blog #4 being my links blog even worked out interestingly, as the window provides a list of articles, rather than "recent post" .

Here's where I got into trouble:
What I also got back was this php error:

Warning: Cannot modify header information - headers already sent by (output started at /**long twisty path **/fredsitelive.com/index.php:9) 
in 
/**long twisty path **/fredsitelive.com/blogs/evocore/_session.class.php on line 197

So one line 197 _session.class.php wants to set a 10-year cookie.
Hmm...

First thought: Ok, on my calling page, I can set a variable, then
simply wrap the cookie statement in _session with an if statement
so it's skipped if we get there from this direction.

What I don't know about B2 would fill volumes so.
Things like, if I don't set the cookie, will I even get back a "latest post" or anything else? I'd rather not wind up with an installation that does a lot of this for obvious "update" reasons, so this might not be the way to go.

I have so far kept all my changes in the skin dept. so that, while an update might require a temp. skin change to keep it running, I wouldn't have a long list of mods that were dependent on the curent code structure.

Is this even the way to go if I'm using 1.6?

Am I asking dumb questions covered on page 1 of the manual?

Since it's Sunday, Is it already too late to run down to the donut shop?

Aren't newbies a pain? :D

5 Apr 09, 2006 19:40

Hi Fredkc,
What I just don't know is what you want to do, we could help you better if you tell us what you want B2 to do...

6 Apr 09, 2006 21:39

Ok, sorry.
What I'm looking to do is have a portion of the latest blog post from: http://fredsitelive.com/blogs/ in a window on my home page,

This looked to be his question as well:

"but I also want to add a small cell to a table on the sites front
(www.sitename.com/index.htm or index.php) page which displays a section of the most recent post (upto 100 words / characters) and a link to the blog.

I can copy/past the text myself each time I post to my blog onto my
home page: http://fredsitelive.com/ (as I have done at the moment)
but I'd rather it pull this than have to update it manually.

If getting a small piece of the latest post from the blog, for my home
page in this manner, requires a lof of changes then I'm better off simply
writing a small piece of php code to just go grab that last entry off the Db
directly and leave the B2 code unchnged.

Right now, there are no changes to my original code. I can update by
using whatever instruction are published by B2. My worst concern would
be having to maybe use a different skin, until I sorted mine out. I value
that simplicity more than having a small sample on my home page.

It looked like the code posted above was doing what I wanted except for
the cookie error I was getting from _session.php which was:

Warning: Cannot modify header information - headers already sent 
by (output started at /**long twisty path **/fredsitelive.com/index.php:9) 
in 
/**long twisty path **/fredsitelive.com/blogs/evocore/_session.class.php on line 197

Heres what's at line 197:

// Set a cookie valid for ~ 10 years:
setcookie( $cookie_session, $this->ID.'_'.$this->key, time()+315360000, $cookie_path, $cookie_domain );

$Debuglog->add( 'ID (generated): '.$this->ID, 'session' );
$Debuglog->add( 'Cookie sent.', 'session' );
}

So what I'm asking is, if I were to set a variable, on my site's home page
like $SomeWierdNameTheyWontUse to 'youbet' , then edit the chunk at
line 197 of _session.php to something like this:

if ($SomeWierdNameTheyWontUse != 'youbet') {
// Set a cookie valid for ~ 10 years:
setcookie( $cookie_session, $this->ID.'_'.$this->key, time()+315360000, $cookie_path, $cookie_domain );

$Debuglog->add( 'ID (generated): '.$this->ID, 'session' );
$Debuglog->add( 'Cookie sent.', 'session' );
}
}

I can skip the cookie line only when the request comes from my home page,
and leave it alone for regular blog use. What I don't know is, if I do this, is
there something else down the line that I'll run into?

Am I better off to just write a small script for my home page that will
fetch me the text?

7 Jan 12, 2007 06:23

I followed these instructions and I get the "
Warning: Cannot modify header information - headers already sent by (output started at /**long " response also!

I think it's trying to send the entire page (headers and ALL) again. I made it reference a stripped down skin that would not send the header info again but it looks like it still is doing so.

Any ideas guys?


Form is loading...