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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.