WebmasterSite.net

Limiting title characters the hard way

Version: 5.1.38
URL:

PrintPrint


Limiting title characters the hard way
Jenny
Forum Regular
Avatar

Usergroup: Customer
Joined: May 11, 2003

Total Topics: 64
Total Posts: 199
quote post #1
Posted 06/19/10 - 3:18 AM:

I have set the limit for characters to be used in a title to 30. That works fine as long as users are actually typing it, but since I get a lot of submissions with titles MUCH longer than that there must be a way around it. I managed to do it by pasting longer titles in the form as well as using the META tag button. Unlike the textarea field for the description the input field for the title doesn't seem to cut back the characters that are over the limit automatically once you click on the field.

So I was thinking I could limit the title output instead. It might not be pretty in some cases, but people will get the point and maybe edit their titles to make them shorter.

I tried something like this, but it's been either producing errors or returning a blank title:


<?php
global $title;
$titlenew = substr($title, 0, 30);
?>

<?php echo $titlenew; ?>
Paul
developer
Avatar

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 65
Total Posts: 7614
quote post #2
Posted 06/19/10 - 2:50 PM:

The beforeaddition plugin could trim it ($object->title = substr($object->title, 0, 30);), but I'll just make it standard. Currently if a spammer submits the form by an automated method it doesn't trim it.
 
Search thread for
Download thread as


Sorry, you don't have permission to post. Log in, or register if you haven't yet.