Gossamer Forum
Home : Products : DBMan : Customization :

$rec{title} page title for mh=1 - would really like page title from record for search engine optimization

Quote Reply
$rec{title} page title for mh=1 - would really like page title from record for search engine optimization
The one thing that I just can't figure out how to do with dbman that still bothers me is that I would really like to pull the record title from the record when max hits = 1.

However I cannot for the life of me figure out how to do this. This means that while many of my records are listed in google, the page title is always generic and neither good for my site being found in google or good for those searching. (if the record title is "18 inch brass clock", the page title when the record is pulled up by visitors or google is still "my site" for everything. There must be a way to pull the record title into the page title, no?)

Can anyone help?

This post from JPDeni back in 1999 seems to be exactly what I want to do:

http://gossamer-threads.com/perl/gforum/gforum.cgi?do=post_view_threaded;post=57592;sb=post_latest_reply;so=ASC;

Quote:
If you're using the "short/long" display, here's what you do.

In sub html_view_success, instead of

Code

$page_title = "Search Results";


use

Code

if (($db_total_hits == 1) or ($maxhits == 1)) {
%rec = &array_to_hash(0, @hits);
$page_title = "$rec{'Title'} in $rec{'Year'}";
}
else {
$page_title = "Search Results";
}


You can put as many fields into the $page_title variable as you want.

Notice I added the word "in" there before the year variable to test it, and now all that is returned for this case is "in" - it simply is not fetching the rec varialbes.

Any ideas?

Last edited by:

Jeff-C: Aug 11, 2005, 2:46 AM
Quote Reply
Re: [Jeff-C] $rec{title} page title for mh=1 - would really like page title from record for search engine optimization In reply to
I've got to ask several questions, just to make sure we're on the same page. They may seem silly, but I think they're important.

Are you using the short/long display mod?

Are you using the "user-friendly" html.pl file mod?

If you have more than record returned from a search, does the page title say "Search Results"?

If it's not fetching the %rec hash, the only thing I can think that's wrong is that you've not got anything in the @hits array. Make sure that the code you have for deciding the page title is after the following:
Code:
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] $rec{title} page title for mh=1 - would really like page title from record for search engine optimization In reply to
JPDeni - you are FANTASTIC!!!

That did it. Somehow that part was moved or removed from above the title section - everything else was working fine, but I do not see those anywhere in the sub view_success until I just added them.

My install of dbman is heavily modded now as it's been growing since 1999 (and was also the program that I started learning perl on... so it's not as neat as it probably should be) and dbman has been evolving to fit my needs ever since then - I now have the short/long display, clickable table, private mailer, image upload modified to a multiple image upload mod (but not the same as the better one posted now as mine started out as a single image upload mod), mod_rewrite for quick record access, and probably some mods that I'm not even thinking of at the moment. It's a really great program made so much better through all the great mods.

Many many many thanks for all of your help throughout the years :)