CodeIgniter Forums
What is the correct way to show small part and read more for an article in the main page? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: What is the correct way to show small part and read more for an article in the main page? (/thread-53627.html)



What is the correct way to show small part and read more for an article in the main page? - El Forum - 08-01-2012

[eluser]ytsejam[/eluser]
Hello ,
I am a newbie. I want to learn how can i show a small part of an article in the main page. and put a read more link to show it in a seperated page?


What is the correct way to show small part and read more for an article in the main page? - El Forum - 08-01-2012

[eluser]minerbog[/eluser]
You could store an intro field for the fist page that only has a snippet of your main post in it.

Or, return the main article and strlen then variable to a shorter length.

If your asking if there is a library for it, then no, there's not. Its going to take some basic php skills to do that.

Gav


What is the correct way to show small part and read more for an article in the main page? - El Forum - 08-01-2012

[eluser]Aken[/eluser]
I would do it one of two ways:

1) As minerbog mentioned, you could add a specific "intro" field. This is helpful if you want your intro text to be used in other places except the main article page. Good for teaser lines and that sort of thing.

2) Assuming you're using MySQL, there is a built-in SUBSTRING() [ or SUBSTR() ] string function available that allows you to pull specific chunks of text. Great way to pull only the first X words of your article. You can then use PHP to remove any partial words at the end, in case your character limit ended mid-word (you could also go back to the end of a sentence).