PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   How-to Forum (http://www.phpdig.net/forum/forumdisplay.php?f=33)
-   -   Can I limit the page title length, that gets saved? (http://www.phpdig.net/forum/showthread.php?t=375)

Wayne McBryde 01-11-2004 07:18 AM

Can I limit the page title length, that gets saved?
 
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 01:19 PM

Hi. In robot_functions.php is the function phpdigCleanHtml.

In that function replace:
PHP Code:

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


with the following:
PHP Code:

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 "";




All times are GMT -8. The time now is 03:15 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.