Hi guys, I'm back for some help. Spent days googling for the answer... cant do it anymore. Could somebody please tell me how to simulate Joomla readmore function. What I mean is: I have a mysql database with news articles. Each article is stored in the 'news' table in the 'content' field. 'content' filed has mixed content HTML and TEXT. so the reference to images and all the html formating stored in that field among the actual article text.

My question is how can I split articles to display short intro with a readmore link to the full text?

I wanna avoid creating an extra field in the database with intro text.

Any help is appreciated. Thank you in advance!

Recommended Answers

All 3 Replies

I use a similar method for creating an rss feed. My solution is to extract only the first paragraph. If needed you could delete some or all tags from it (e.g. img).

I use a similar method for creating an rss feed. My solution is to extract only the first paragraph. If needed you could delete some or all tags from it (e.g. img).

Hi mate, thx for helping me out again:) So how do you tell your script to get only the first paragraph? I was thinking of counting characters but because of the html tags this method is not reliable.

You can use a regex to search for all text between <p> and </p>, probably something like:

<p>(.*?)</p>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.