PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 01-11-2004, 07:18 AM   #1
Wayne McBryde
Orange Mole
 
Join Date: Oct 2003
Location: NC, USA
Posts: 34
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
__________________
Wayne Mcbryde
http://LakeNormansWeb.com
We search all of Lake Norman!
Wayne McBryde is offline   Reply With Quote
Old 01-11-2004, 01:19 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
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 "";

__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Manually set title for spidered page bvr How-to Forum 3 11-22-2005 12:45 PM
Display first H2 tag as title instead of page title mdavila How-to Forum 5 02-27-2005 06:48 PM
How to index only part of page <title>? visioneer How-to Forum 4 08-24-2004 10:24 PM
Page Title not shown in Result?? stefanw Troubleshooting 5 05-04-2004 11:31 PM
"limit to" option on from page? atticus1214 How-to Forum 3 03-03-2004 01:05 PM


All times are GMT -8. The time now is 12:02 AM.


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