Textpattern Forum

You are not logged in. Register | Login | Help

#1 2005-02-19 05:08:14

supa
Plugin Author
Registered: 2005-02-10
Posts: 27
Website

[archived] sab_substr

Notice: This thread is archived, this plugin is no longer available. rvm_substr offers this functionality

**********************************************************

http://www.bluecamel.org/software/textpattern/sab_substr.txt

<code>&lt;txp:sab_substr limit=“10” trail=”…”&gt;content to take a substring of like &lt;txp:title /&gt;&lt;/txp:sab_substr&gt;</code>

This is a simple plugin to cut a string of text at a specified character limit, then add a string to the end, like ellipses.

It will take an article title and trim it down to a specified character limit then add an ellipses. Possibly used for article navigation (prev/next) or an article list where you want to keep the titles short.

Example:

<code>&lt;txp:sab_substr limit=“10” trail=”…”&gt;long string of text&lt;/txp:sab_substr&gt;</code>

will output

“long strin…”

<h3>Reference</h3>
<ul>
<li><strong>trail=</strong> – The string you want appended to the result. It will NOT be appended UNLESS the content was trimmed. Defaults to <strong>…</strong>.</li>
<li><strong>limit=</strong> – The length of the string you want returned, minus the length of <strong>trail</strong>. Defaults to <strong>10</strong>.</li>
</ul>

Last edited by supa (2005-05-20 12:55:22)

Offline

#2 2005-05-18 23:40:58

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

Re: [archived] sab_substr

Has anyone had success using this? I applied the tag but the title still remains on two lines. I modified it to only show 5 characeters and it remained the same.

Thanks in advance

Offline

#3 2005-05-19 02:19:48

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

Re: [archived] sab_substr

I used this a little a while ago (rc1&rc2), but not recently. I wonder if the new humane titles are interfering? What version of txp are you on?

Offline

#4 2005-05-19 06:28:24

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

Re: [archived] sab_substr

the one on the front page. I;m trying to use it in a form, but no joy

Offline

#5 2005-05-19 21:56:26

supa
Plugin Author
Registered: 2005-02-10
Posts: 27
Website

Re: [archived] sab_substr

Thanks sekhu for PMing me!

I wasn’t aware of any problem with this plugin. It uses standard PHP and only relies on one TXP function (parse()). I’ll update my copy of TXP and see if I can figure out what’s wrong!

-sab

Offline

#6 2005-05-19 22:18:50

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

Re: [archived] sab_substr

wow thanks. so email does have a purpose!

Offline

#7 2005-05-19 22:22:01

supa
Plugin Author
Registered: 2005-02-10
Posts: 27
Website

Re: [archived] sab_substr

Hm, well, I’m afraid I don’t have good news for you :( It works fine for me!

Can you describe the context that you’re using it in? (form, in any ef/else blocks, when the form gets output, etc)?

-sab

Offline

#8 2005-05-19 22:54:11

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

Re: [archived] sab_substr

damn I don’t seem to be having much luck :(

Ok the context: http://www.sekhu.net/txpattern/

The form in which I’m using it:

<pre><h2 class=“music”>
<sab_substr limit=“10” trail=”…”>
<txp:category1 link=“y” />
</sub_str>
</h2><br />
<h3 class=“music”><txp:permlink><txp:title /></txp:permlink></h3><br />

<p>
<txp:beginning length=“100” /><div class=“mmore”><txp:permlink>continue reading</txp:permlink></div>
</p></pre>

So the box with “music” as the title would have that two line title link truncated to 10 characters. I am using this within article_custom – is that going to cause an issue?

Cheers

Offline

#9 2005-05-20 02:26:48

supa
Plugin Author
Registered: 2005-02-10
Posts: 27
Website

Re: [archived] sab_substr

Okay, well hopefully you didn’t copy and paste that and you just retyped it wrong :P

1) The tag is <code><txp:sab_substr limit=“10” trail=”…”></code>, not <code><sab_substr limit=“10” trail=”…”></code>
2) The tag is <code></txp:sab_substr></code>, not <code></sub_str></code>

Also, remember, that when link=“y” there is some text prepended to the category to make the link (“<code><a href=“blah”>category&lt;/a></code>”). That’s factored into the “limit” attribute of sab_substr. In that case, I don’t think sab_substr will do what you need. At least not with the <code><txp:category1 link=“y” /></code> tag.

-sab

Last edited by supa (2005-05-20 02:30:30)

Offline

#10 2005-05-20 06:24:37

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

Re: [archived] sab_substr

> supa wrote:

> Okay, well hopefully you didn’t copy and paste that and you just retyped it wrong :P

1) The tag is <code><txp:sab_substr limit=“10” trail=”…”></code>, not <code><sab_substr limit=“10” trail=”…”></code>
2) The tag is <code></txp:sab_substr></code>, not <code></sub_str></code>

Hmmm – I was going by your example at the top of the page :)

<pre>Example:
<sab_substr limit=“10” trail=”…”>long string of text</sab_substr>

will output</pre>

so this won’t work with links?

Cheers anyway

Offline

Board footer

Powered by FluxBB