You are not logged in.
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><txp:sab_substr limit=“10” trail=”…”>content to take a substring of like <txp:title /></txp:sab_substr></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><txp:sab_substr limit=“10” trail=”…”>long string of text</txp:sab_substr></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
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
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</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
> 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