Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-13 10:03:51

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#2 2007-12-13 10:05:58

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: How to limit the characters in fields?

rss_auto_excerpt possibly?

Offline

#3 2007-12-13 10:55:58

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#4 2007-12-13 14:54:55

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#5 2007-12-13 20:18:49

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

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

#6 2007-12-14 08:23:54

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#7 2007-12-14 13:38:39

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

Board footer

Powered by FluxBB