Recent Topics

1 Dec 08, 2008 22:38    

My b2evolution Version: 2.x

OK so basicly now I am very frustrated from my incompetence, cuz I am 3 weeks strugling with what should be very simple issue...
So I want to have post content preview only on MAIN pages of my blogs... So did some research and came with solution to clone the "content_teaser" function in _item.class.php and to limit the words (not chars) parsed to 250. Now since 3 weeks... 8| I am trying to edit _item_content.inc.php and to say IF USER IS ON MAIN PAGE {
$Item->content_preview ( array(
'before' => '',
'after' => '',
) );
}
ELSE {
$Item->content_teaser( array(
'before' => '',
'after' => ''
) );
}
Yeah, but i don't seem to get from where should I compose my IF statement... Tried to search URL variables, main page, content preview, post preview...
OK can anyone PLEASE tell me how can I tell if I am viewing the main page or some post...
My main blog is in Bulgarian but there is also English part: http://dimitrov.eu.org/blog/en/
Yes and !M button doesn't work for me, because it breaks the posts with this very annoying "Follow by:" text...

P.S. The modified code for "content_preview" in _item.class.php is:

function wordlimit($string, $length = 50, $ellipsis = " [...]")
{
$words = explode(' ', $string);
if (count($words) > $length)
return implode(' ', array_slice($words, 0, $length)) . $ellipsis;
else
return $string;
}

function content_previewer( $params )
{
// Make sure we are not missing any param:
$params = array_merge( array(
'before' => '',
'after' => '',
'disppage' => '#',
'stripteaser' => '#',
'format' => 'htmlbody',
), $params );

$r = $this->get_content_teaser( $params['disppage'], $params['stripteaser'], $params['format'] );

$r = $this->wordlimit($r);

if( !empty($r) )
{
echo $params['before'];
echo $r;
echo $params['after'];
}
}

PLEASE HELP !!!

2 Dec 09, 2008 19:56

Would I be right in guessing that you want to automate ## words of teaser before a "read more" kinda link?

If so then you might want to have a meander through our rss plugin, it's got a word count thing that might help you

¥

3 Dec 10, 2008 00:30

Hi, thanks for the reply!

I'll go and read about the rss plugin and then after I have the new information I'll infrom everyone if there are answers right for me...

P.S. I was wondering if there is functionality like in Codeigniter where I can work with lets say the third URL variable - in my case http://dimitrov.eu.org/blog/en/general/christmas So in Codeigniter I can catch this variable by $url[3], which will be "christmas". And I would like to check if $url[3]!=NULL or $url[3]!=''
That is how I know that the user is looking at the main page... I hope I explained it as I wanted to...

4 Dec 10, 2008 10:44

There are ways of detecting if you're on the main page or not, but the chances are you just need to look at $disp

<?php
switch( $disp )
  case 'posts' : // chances are this is where you want to show teasers ;)
    // do teaser stuff
    break;

  case 'single' :
  default : // chances are this is where you want to show full post
    // do full post stuff
    break;
}
?>

Alternatively you can create a _posts.main.php && _single.main.php in your skins/[skin]/ folder and then just change the relevant bits ;)

¥

5 Feb 22, 2009 20:39

Thanks to the help of ¥åßßå I've managed to finish the content preview only on MAIN pages. I've cloned the "content_teaser" function in ../inc/items/model/_item.class.php, renamed it to content_preview, and added one additional function wordlimit:

	function wordlimit($string, $length = 100, $ellipsis = "  [...]")
	{
	   $words = explode(' ', $string);
	   if (count($words) > $length)
	       return implode(' ', array_slice($words, 0, $length)) . $ellipsis;
	   else
	       return $string;
	}
	
	function content_preview( $params )
	{
		// Make sure we are not missing any param:
		$params = array_merge( array(
				'before'      => '',
				'after'       => '',
				'disppage'    => '#',
				'stripteaser' => '#',
				'format'      => 'htmlbody',
			), $params );

		$r = $this->get_content_teaser( $params['disppage'], $params['stripteaser'], $params['format'] );

		$r = $this->wordlimit($r);
		
		if( !empty($r) )
		{
			echo $params['before'];
			echo $r;
			echo $params['after'];
		}
	}

Finaly I've modified _item_content.inc.php in the "skins" directory as replacing

		    $Item->content_teaser( array(
				'before'      => '',
				'after'       => '',
			) ); 


with the folowing:

		switch( $disp ) {
		  case 'posts' : // chances are this is where you want to show teasers ;)
		    // do teaser stuff
			$Item->content_previewer( array(
				'before'      => '',
				'after'       => '',
			) );
		    break;

		  case 'single' :
		  default : // chances are this is where you want to show full post
		    $Item->content_teaser( array(
				'before'      => '',
				'after'       => '',
			) );
		    break;
		}


Thanks ¥åßßå , thanks all. Cheers!


Form is loading...