Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-07-27 13:51:57

fas.khan
Member
From: Paris
Registered: 2007-06-06
Posts: 41

<txp:title /> Title Trim ...

Hello all,

I am into this problem where I want to trim the Title (<txp:title />) length and put (…) at the end. It seems that this ‘sab_substr’ plugin can do the job, but I really dion’t know where to get this plugin.

The author of the site www.bluecamel.org is not working anymore and that is where this plugin is located.

Can I anyone suggest me where to get this plugin or any other way how to accomplish it ?

Thanks.

Offline

#2 2007-07-27 23:02:49

fas.khan
Member
From: Paris
Registered: 2007-06-06
Posts: 41

Re: <txp:title /> Title Trim ...

Any help, any one ? pleaaase :(

Offline

#3 2007-07-28 12:07:49

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

Re: <txp:title /> Title Trim ...

See here

Offline

#4 2007-07-28 14:26:59

fas.khan
Member
From: Paris
Registered: 2007-06-06
Posts: 41

Re: <txp:title /> Title Trim ...

Hello,

I am so so thankful to you that you put this code here … I am a TUDelft Student and making a blog site for my Masters Program.

I am so sorry but I couldn’t implement your code … I am writing the lines the way I used my code …

I am showing the title of posts in a list and want the title to be trimmed from your function.

CODE
————

<ul class=“articles”>
<txp:php>

// your code

function sab_substr($atts, $thing)
{ extract(lAtts(array( ‘limit’ => 30, ‘trail’ => ‘…’ ), $atts));

assert_int($limit); if (strlen(utf8_decode($thing)) > $limit) { $thing = preg_replace(‘/^(.{‘.$limit.’}).*$/u’, ‘$1’, $thing); echo escape_output($thing).$trail; } else { echo escape_output($thing); } }

</txp:php>

// your code ends here

<txp:article_custom section=“article” limit=“5” form=“recent_articles_list” />
</ul>

The Form (recent_articles_list ) is as follows:-
—————————————————————————————-

<li>
<a href=”<txp:permlink />” title=”<txp:title />”>

<txp:sab_substr><txp:title /></txp:sab_substr><br>

</a>

</li>

I put the limit of five article titles to be shown … and what happens is that that <li> becomes empty as there is nothing inside it …
——————————————————————————————————————————————————————————————————————————————
and <txp:title /> is repeated five times on the top of the page …
———————————————————————————————————————

Just like this

<txp:title /><txp:title /><txp:title /><txp:title /><txp:title />

I would be very thankful for your help.

Regards,
Faisal

Last edited by fas.khan (2007-07-28 14:43:11)

Offline

#5 2007-07-28 14:38:51

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

Re: <txp:title /> Title Trim ...

Ah, I’ve updated the code in the other topic. The ‘parse($thing)’ line was missing. This ex-TUEindhoven student doesn’t always test his code before publishing it on forums ;)

Btw, if 30 chars is too long, use something like <txp:sab_substr limit="20"><txp:title /></txp:sab_substr>

Last edited by ruud (2007-07-28 14:53:33)

Offline

#6 2007-07-28 17:36:37

fas.khan
Member
From: Paris
Registered: 2007-06-06
Posts: 41

Re: <txp:title /> Title Trim ...

It is fine … but one of the two problems are solved …

The first problem was that it shows <txp:title /> all the way … in every title … but now It shows it perfectly …

The second problem was that it shows the Titles way way up left the page … instead of showing inside of <li> …

which is still there … I don’t know what is the problem here but may be you know … i attach the picture to show you better what I mean …

I put the picture here …

http://www.epastudents.org/img/up/test.png

It is suppose to come at red boxes … but it it coming to blue box …

Regards,
Faisal Khan

Offline

#7 2007-07-28 17:45:28

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

Re: <txp:title /> Title Trim ...

Oops, try replacing echo with return in the code. The code in the other example is updated again.

Last edited by ruud (2007-07-28 17:46:33)

Offline

#8 2007-07-29 13:11:27

fas.khan
Member
From: Paris
Registered: 2007-06-06
Posts: 41

Re: <txp:title /> Title Trim ...

still the same problem Ruud … :(

I am so sorry :(

Offline

#9 2007-07-29 13:51:35

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

Re: <txp:title /> Title Trim ...

Strange. Oh well, let’s turn it into a real plugin then. That should definitely work (and it’s easier to use anyway). You can get it here

Offline

#10 2007-07-29 14:49:00

fas.khan
Member
From: Paris
Registered: 2007-06-06
Posts: 41

Re: <txp:title /> Title Trim ...

Whoa …

Now this is the way Dutch Bell the Cats … :-)

Done ! …

Thank you so so much …

Offline

Board footer

Powered by FluxBB