我还需要实现“阅读更多”功能

I want to implement a "read more" feature when I'm displaying content. I want to cut off the text either at 6 lines or by number of words (but prefer by lines, unless you have different advice).

I'm guessing I will have to use javascript for this and calculate the text cutoff somehow. But I'm not quite sure what I should be doing, and if there's any calculation or other steps to do on the php end. Can someone give me some advice? Are there jquery plugins that could help with this?

I've used this: Expander-Jquery-Plugin. And it's pretty cool :)

I hope this helps.

You can use wordwrap with substr function of php

You can do this in PHP, make two variables and truncate the "teaser" text variable to desired length

$teaser =substr($long_text, 0, 250); //250 chars

So, you have two variables, $teaser and $long_text. Use them as you like. You can use javascript to show/hide it Or if you decide to use a link (to a whole article page). You can altogether ignore the $long_text.

Say your content exists in a file, then you need to read 200 characters with it using php, then go ahead and read until you find a dot so that you know you have read until the end of the sentence. Then your "Read More" read can point to a page for example yourpage.php?fullcontent=yes and when the full content argument is given you read all the file.