Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How to limit the characters in fields?
Hi again :)
I will love to know how can I limit the characters please?
I’m showing excerpts of articles on the main page and I want to limit the characters so it will not mess up my design please.
I want to make it into the excerpt & title tags:
<txp:excerpt /> <txp:title />,
so there will be a limit only in a specific form.
Last edited by THE BLUE DRAGON (2007-12-19 17:16:30)
Offline
Offline
Re: How to limit the characters in fields?
iblastoff wrote:
rss_auto_excerpt possibly?
thanks but I prefer not using a plugin please if it’s possible.
(just by adding some code to the tags or something please).
Offline
Re: How to limit the characters in fields?
thanks but I prefer not using a plugin please if it’s possible.
You have to use plugins for these kind of things – and why you prefer some kind of php-code mess, when plugin much better and efectiness, as iblastoff pointed out. But what the ever, if you want to do it with out any plugins, here you go – as regular tags can’t do what you’re asking.
Title:
<txp:php>
$limit = 10;
$tit = strip_tags(title());
$tit = preg_replace('/^(.{'.$limit.'}).*$/u', '$1', $tit);
echo $tit;
</txp:php>
Excerpt:
<txp:php>
$limit = 50;
$bod = strip_tags(excerpt());
$bod = preg_replace('/^(.{'.$limit.'}).*$/u', '$1', $bod);
echo $bod;
</txp:php>
Cheers!
Last edited by Gocom (2007-12-13 14:55:27)
Offline
Re: How to limit the characters in fields?
THE BLUE DRAGON wrote:
thanks but I prefer not using a plugin please if it’s possible.
(just by adding some code to the tags or something please).
if there was just ‘some code’ you could add to a tag then the plugin wouldn’t have needed to be written would it?
Offline
Re: How to limit the characters in fields?
lol!
Thank you guys!
I’m going to try it out.
I prefer not to use a plugin because I need to limit just only one form,
and not to take control all over all the excerpts out there on my site.
But I will try it if you say it’s better, and I will see if I can make it work only for one specific form ;)
Offline
Re: How to limit the characters in fields?
But I will try it if you say it’s better, and I will see if I can make it work only for one specific form ;)
Huh? Ofcorse you can. Plugins don’t modify original txp-tags nor functions, modifications do.
Cheers!
Last edited by Gocom (2007-12-14 13:39:13)
Offline