Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-15 14:18:12

Zodiac
Member
Registered: 2005-04-22
Posts: 26

Truncate Titles

Hey guys, I did a quick search for this and everything that came up was circa 2005, so I thought I would ask again…

What is the best way to truncate titles in my default page?


Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”

Offline

#2 2008-12-15 14:52:28

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Truncate Titles

I think sab_substr could do that for you.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2008-12-15 14:54:56

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Truncate Titles

Probably, rvm_substr is a little better than the one suggested by Stuart.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2008-12-15 14:55:15

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Truncate Titles

Or rvm_substr, which might be better as it’s newer and understands that splitting in the middle of an XHTML tag is bad…

EDIT: Maniqui had faster fingers :-)

Last edited by Bloke (2008-12-15 14:55:31)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2008-12-15 15:08:24

Zodiac
Member
Registered: 2005-04-22
Posts: 26

Re: Truncate Titles

ha… interesting how it works, so for like, this block of code:

<h4>Previous Articles</h4> <div id="prevart"><ul><txp:rvm_substr length="50"><txp:article_custom section="article" limit="20" sortby="Posted" sortdir="desc" form="recentarticles" /></txp:rvm_substr></ul></div>

It actually limits the entire list to 50 characters, rather than each iteration…. doh!

Last edited by Zodiac (2008-12-15 15:09:33)


Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”

Offline

#6 2008-12-15 15:14:17

Zodiac
Member
Registered: 2005-04-22
Posts: 26

Re: Truncate Titles

Can you append the rvm_substr to each list element? Like, in the txp:article tag?


Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”

Offline

#7 2008-12-15 15:20:20

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Truncate Titles

Yes. You should enclose the <txp:title /> tag in your form to do what I think you want.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#8 2008-12-15 15:22:07

Zodiac
Member
Registered: 2005-04-22
Posts: 26

Re: Truncate Titles

I list like, previous entries and some of the titles are longer than the sidebar, so they wrap, and wrap, and wrap… and I’d rather just replace the ends with a … and be done with it.


Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”

Offline

#9 2008-12-15 15:35:15

Zodiac
Member
Registered: 2005-04-22
Posts: 26

Re: Truncate Titles

thebombsite wrote:

Yes. You should enclose the <txp:title /> tag in your form to do what I think you want.

hmmm… I am confused by what you mean…

Can you show me an example?


Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”

Offline

#10 2008-12-15 15:38:35

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Truncate Titles

In your form template called “recentarticles” you should wrap the title tag something like:-

<txp:rvm_substr length="50"><txp:title /></txp:rvm_substr>

Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#11 2008-12-15 15:48:01

Zodiac
Member
Registered: 2005-04-22
Posts: 26

Re: Truncate Titles

DuH!

Yes of course… very nice…

It sort of works, ha, it looks like 35 characters means different things to different titles, but it works!

Thanks guys!


Special Order 937: “Nostromo Rerouted To New Coordinates. Investigate Life Form. Gather Specimen. Priority One. Insure Return Of Organism For Analysis. All Other Considerations Secondary. Crew Expendable.”

Offline

#12 2008-12-15 16:34:56

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

Re: Truncate Titles

The character limit includes spaces, punctuation etc.

Offline

Board footer

Powered by FluxBB