PDA

View Full Version : Can I limit the page title length, that gets saved?


Wayne McBryde
01-11-2004, 08:18 AM
I run a community web site and search engine (phpdig of course). My database currently has over 800 sites. My problem is, some sites (only a few) have a title that reads more like a long description. An example is http://lakenormansweb.com and search for “real estate”. This is 1 example but there are others. I had 1 site that I deleted from my database because they had real estate about 10 times in the title of every page on their site. They had about 30 pages. So if someone searched on real estate the first 3 pages of results were all from this site. So, is there any way to set phpdig to only save the first 60 or 70 characters of the title, or something like that?

Thanks

Charter
01-11-2004, 02:19 PM
Hi. In robot_functions.php is the function phpdigCleanHtml.

In that function replace:

if ( eregi("<title *>([^<>]*)</title *>",$text,$regs) ) {
$title = $regs[1];
}
else {
$title = "";
}

with the following:

if ( eregi("<title *>([^<>]*)</title *>",$text,$regs) ) {
$title = $regs[1];
if (strlen($title) > X) { // replace X with max length before truncating
$title = substr($title,0,Y) . "..."; // replace Y with desired length
}
}
else {
$title = "";
}