|
02-25-2005, 02:19 PM | #1 |
Green Mole
Join Date: Feb 2005
Posts: 11
|
Display first H2 tag as title instead of page title
We have thousands of pages in our site and most of the pages within a section share the same page title, so the search results can look confusing since all the titles on the results page have the same text. Is it possible to get phpdig to display the text in between the h2 tags on the page? since that is a better reflection of the title of the page?
Thanks, -Marc |
02-26-2005, 09:37 PM | #2 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Look for the phpdigCleanHtml function in the robot_functions.php file, and in the if-else "//extract title" code snippet, try replacing title with h2 and see if that works.
__________________
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. |
02-27-2005, 07:04 PM | #3 |
Green Mole
Join Date: Feb 2005
Posts: 11
|
Such as this?
//extracts title if (preg_match('/< *h2 *>(.*?)< *\/ *h2 *>/is',$text,$regs)) { $title = trim($regs[1]); } else { $title = ""; } |
02-27-2005, 07:29 PM | #4 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Yes, try that and see if it sets the title to be the content between the h2 tags. BTW, how many h2 tags are there per page? The preg_match will look for the first h2 to match.
__________________
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. |
02-27-2005, 07:30 PM | #5 |
Green Mole
Join Date: Feb 2005
Posts: 11
|
there are more than 1. I tried it but it picks up the first one, so it works but shows the content for the wrong H2. Is it possible to choose which H2 it picks up?
|
02-27-2005, 07:48 PM | #6 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Yep, preg_match matches on the first h2 tag. Try the following instead:
Code:
//extracts title if (preg_match_all('/< *h2 *>(.*?)< *\/ *h2 *>/is',$text,$regs,PREG_SET_ORDER)) { $title = trim($regs[X][1]); // set X to a number } else { $title = ""; } You could also do something like the following: Code:
// assumes there are at least three h2 tags $title = trim($regs[0][1]." ".$regs[1][1]." ".$regs[2][1]);
__________________
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. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Duplications of Title and Meta Tag Info | mokele | Troubleshooting | 1 | 03-24-2006 12:15 PM |
title tag | worldwealth | How-to Forum | 1 | 12-13-2005 05:19 PM |
Manually set title for spidered page | bvr | How-to Forum | 3 | 11-22-2005 01:45 PM |
Page Title not shown in Result?? | stefanw | Troubleshooting | 5 | 05-05-2004 12:31 AM |
Can I limit the page title length, that gets saved? | Wayne McBryde | How-to Forum | 1 | 01-11-2004 02:19 PM |