Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-08-16 17:03:12

Sono Juventino
Member
From: Skedsmo, Norway
Registered: 2007-12-22
Posts: 81

How to print just 100 letters from excerpt?

Hello.

Is it possible to print just 100 letters from the excerpt of one news? It would make my layout so much easier to create. How can I do that?

Thanks for any help. :)

Offline

#2 2008-08-16 17:32:45

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,730
Website

Re: How to print just 100 letters from excerpt?

check the excerpts plug-ins in txp resources. There are several plugins that do a certain number of words like rss_auto_excerpt. I believe some of the ‘…beginning’ plugins also work witha character limit.

Note it’s important that any code your excerpt or article may contain (e.g. bold or italic) is either stripped out of the body/excerpt entirely or the HTML-tags correctly closed or it can affect the rest of the layout. I know that rss_auto_excerpt does that, not sure about the others.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2008-08-16 17:55:34

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: How to print just 100 letters from excerpt?

plugin rvm_substr (can create substrings without causing invalid HTML and UTF-8)

Offline

#4 2008-08-16 19:12:21

Sono Juventino
Member
From: Skedsmo, Norway
Registered: 2007-12-22
Posts: 81

Re: How to print just 100 letters from excerpt?

Thank you very much for you replies!

ruud: I tried rvm_subsrt, but it breaks my Textile markup. I could use it just on the headlines to controll text flow in normal view, but once you increase text size, you will see that the text is hacked. Maybe not that important, but maybe there’s a way around?

Thanks.

Offline

#5 2008-08-16 21:20:33

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: How to print just 100 letters from excerpt?

rvm_substr doesn’t handle textile, but if you use it on the <txp:excerpt /> string, it should work. If not, that’s a bug.

Offline

#6 2008-08-16 22:23:04

Sono Juventino
Member
From: Skedsmo, Norway
Registered: 2007-12-22
Posts: 81

Re: How to print just 100 letters from excerpt?

I used it on excerpt, so it’s a bug then.

Offline

#7 2008-08-17 07:53:13

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: How to print just 100 letters from excerpt?

Can you provide an example? A block of HTML that the <txp:excerpt /> tag would normally produce, how you used rvm_substr and what the resulting HTML code was.

Offline

#8 2008-08-18 13:51:04

Sono Juventino
Member
From: Skedsmo, Norway
Registered: 2007-12-22
Posts: 81

Re: How to print just 100 letters from excerpt?

Looks like I used the sab-version the first time, but now I tried rvm_substr. I’m only getting outputed three words, even if I’m using 100 as a limit.

Live example: http://2dropsdesign.com/

(Fom article_small)

   <div class="article-small">
      <txp:article_image thumbnail="1" />
      <h3 title="Les hele nyheten"><txp:permlink><txp:title /></txp:permlink></h3>
      <txp:rvm_substr limit="100"><txp:excerpt /></txp:rvm_substr>
    </div>

Last edited by Sono Juventino (2008-08-18 13:51:39)

Offline

#9 2008-08-18 14:24:08

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: How to print just 100 letters from excerpt?

I’m guessing the <p>Sed ut per…</p> part is a result of rvm_substr.
If you didn’t use rvm_substr, what what would <txp:excerpt /> output in the HTML code?

Offline

#10 2008-08-18 16:59:49

Sono Juventino
Member
From: Skedsmo, Norway
Registered: 2007-12-22
Posts: 81

Re: How to print just 100 letters from excerpt?

You are absolutely right. The whole first paragraph with text when you press on the headline is always the excerpt on our site. The text belov is the full excerpt.

(Sed ut perspiciatis unde omnis iste natus error sit volu ptatem accus antium dolo remque laud antium, totam rem aperiam, eaque ipsa quae ab. Sed ut persp iciatis unde omnis iste natus error sit volu ptatem accus antium dolor emque lauda ntium, totam rem aperiam, eaque ipsa quae ab.)

Last edited by Sono Juventino (2008-08-18 17:03:54)

Offline

#11 2008-08-18 19:08:01

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: How to print just 100 letters from excerpt?

Problem found. Please read the plugin documentation ;)
You’re using ‘limit’ instead of ‘length’. By default the ‘length’ attribute is set to 10, causing only 10 characters to show. What you want is this:

<txp:rvm_substr length="100"><txp:excerpt /></txp:rvm_substr>

If you’d switched the website status to testing or debug you should have seen a warning about an unknown attribute being used.

Last edited by ruud (2008-08-18 19:08:55)

Offline

#12 2008-08-19 15:51:48

Sono Juventino
Member
From: Skedsmo, Norway
Registered: 2007-12-22
Posts: 81

Re: How to print just 100 letters from excerpt?

Ok, I see. I just copied the example found in “view” at the admin – plugin site. I recomend you to change the example. ;)

Thanks for all help, ruud. You’re my hero. ;)

Offline

Board footer

Powered by FluxBB