read more

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
michu

read more

Post by michu »

hey all..
i ve a question.. is there a feature or a plugin, which enables me to "cut down" an blog entry after (for example) 300 chars? and a "<read more...>" will be instertet. i think this would make the overview cleaner...

thanks in advance
michu

ps an example

-----------------
Article 1:
blah blah blah blah
blah blah blah blah
blah blah <read more...>


Article 2:
blah blah blah blah
blah blah blah blah
blah blah <read more...>

-----------------
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: read more

Post by garvinhicking »

Yes, this comes bydefault with serendipity.That's why our distinction "Entry Body" and "Extended Body" isthere.:-)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

The extended entries is the way to go. It allows you to enter only what you want in the overview as the article body, then the rest of the article in the extended body.

If you really want to truncate articles, you'd need to edit your template. In entries.tpl, find

Code: Select all

            <div class="serendipity_entry_body">
                {$entry.body}
            </div>
and change it to

Code: Select all

            <div class="serendipity_entry_body">
                {if $is_single_entry}
                {$entry.body}
                {else}
                {$entry.body|truncate:300:"<a href='`$entry.link`'>...Read More</a>":false}
                {/if}
            </div>
That's set up from the Smarty site http://smarty.php.net/manual/en/languag ... uncate.php, so it ought to work, but when I tried it on my site, I got weird lengths for the truncation.

Maybe I'd better look into upgrading or something. I use the extended entry feature, though.

Good Luck!
Judebert
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

ROTFL.Dang. Ijust wrote something like that in german :-D

See, that happens when people crosspost ;)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

I've been playing with truncate as well, and I can't figure out why it doesn't actually truncate at the number of characters I specify, for example I might say 50 characters and it seems to randomise this from 39 to 70 characters. Any ideas?

Also, in response to the previous post, be careful about truncating posts in overview mode because the code judebert provided doesn't separate html from text, so if you have an image before entry text, it will truncate somewhere, who knows where, and could totally wreck what you're trying to achieve. Definitely use the extended body instead of smarty script!

I've added a read more to the andreas08 theme I'm working on, which I hope to release soon, but really need to finish my themes checklist and update all themes before I go releasing more new themes. If anyone reads this before I release the theme, either pm me or comment on my blog and I'll send you the instructions to make this work.

Carl
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Carl!
carl_galloway wrote:I've been playing with truncate as well, and I can't figure out why it doesn't actually truncate at the number of characters I specify, for example I might say 50 characters and it seems to randomise this from 39 to 70 characters. Any ideas?
I think truncates cuts at a word boundary. You might need to look up the documentation on http://smarty.php.net/ to set another parameter that cuts at character boundaries?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

On the other hand, I had the same problem as Carl. When I said 50 words, it cut to around 50 words. Sometimes as little as 10. When I said 300 characters, it got really weird.

I'm not sure what causes it, but I've seen the same thing. Safer to just stick with extended entries.
Judebert
---
Website | Wishlist | PayPal
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

mmm, thing is though, I want to use it to truncate the homelink in the banner. I've been searching out users of my themes and have discovered that quite a few actually use really long post titles, and any theme that uses the homelink could end up being badly thrown out. I thought truncate would solve the problem, and it does, just erratically. Any other thoughts?

Carl
Post Reply