Jump to content

blog read more feature


chinclub

Recommended Posts

I am writing a simple blog script.  I have been looking for a tutorial that goes beyond the very basics.  The one thing I can't find a code for is how to deal with the line break that tells the script to stop there and add the (Read more) link.

 

In my basic php knowledge I know I could just have two seperate fields in the post column, one for the intro part and one for the remainder of the article.  I was wondering if this was the right way or if there was something easier.

 

Any help would be great.

 

 

Link to comment
https://forums.phpfreaks.com/topic/282201-blog-read-more-feature/
Share on other sites

You can use explode()

In your txt you can use BBCode Ex:

 

$txt = 'balbalbalbal
[***]
blablablablala 111';

$txt = explode('[***]', $txt);

 

echo "First part: $txt[0]<br>";

echo "Rest of it: $txt[1]";

 

You can also cut after a certain number of characters or after a certain number of words or phrases.

 

after 10 charcaters:

$string = substr($string,0,10).'...';
 

After x number of words
http://www.lullabot.com/blog/article/trim-string-given-word-count

After x number of phrases
http://gelembjuk.com/index.php?option=com_content&view=article&id=61:split-text-for-sentences-with-php&catid=37:php&Itemid=56

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.