#2 May 31, 2007 06:48
I have a multiuser blog and I would like to display only the first paragraph of each article (or cut the article off after a certain number of words). I know that the author can use the M! button when writing the post but I don't want the "More" button to be displayed when viewing that post on the author's blog, I just want the article to "cut off" after a certain length on the link blog page.
I wonder there's a way to count the number of words or characters in the post and then only omit everything else when displaying on the link blog page. Any assistance is greatly appreciated.
One little problem: $cut doesn't count if $format isn't 'xml'. See http://doc.b2evolution.net/v-1-9/__filesource/fsource_evocore__blogsincMODELitems_item.class.php.html#a1220 and http://doc.b2evolution.net/v-1-10/__filesource/fsource_evocore__blogsincMODELitems_item.class.php.html#a1221 for the line of code that shows this to be the situation. I do not know what will happen if you make the format be xml. Probably won't show images or have links be links?
robrockley what do you mean by "on the link blog page"? You can get rid of the text that shows up for both "read more" and whatever it says on the permalink page, but first it'll help to know what you're asking about. Got a link where we can see what you don't want?
Hrmm, ok, then i have no clue.
Thank you both (Balupton and EdB) for your feedback. I have a multiuser blog. What I'd like to do is display the first 150 words of each post on the 'Blog All' page but display the full (non-truncated) post on the user's blog page as it would normally appear. I'd like to display an ellipsis (...) after the first 150 words.
I did look at the technical documention for the content() and get_content() functions. If $format is passed as 'xml' to the content() function, the post text does get get off at whatever value is specified for $cut.
I'm presuming that the code within the get_content() function that does this when $format = 'xml' is the following:
If I changed that to:
and set $cut to 150 on the Blog All _main.php file then perhaps this would accomplish my goal. I guess there's one one way to find out ;)
Yup. The thing is if word 150 is the src part of an img tag or the href part of a link it'll be worse than a dangling participle. Whatever that is. Meaning I don't think it'll finish the tag meaning it'll be b-a-d for your visitors.
But if you try it you'll be the expert on what happens!
The best bet would just be to output unformatted plain text, and if that still outputs the '' etc then do a regex or something to remove those.