Gossamer Forum
Home : Products : DBMan : Customization :

short/long problems if you specify a different mh

Quote Reply
short/long problems if you specify a different mh
Hi,
I am new to this forum (and relatively new to DBMAN), but I encountered a problem that I thought others might see.
(I searched the forum but was unable to find a post regarding this issue. )
I installed the short/long mod and all seemed to be working fine until I did a search that specified a max number of hits per page different from the default $db_max_hits.
The short display appeared correctly, with links to the additional pages of search results.
The problem appeared when I selected one of those subsequent pages and then tried to click on a link for a long record. The long record appeared to be empty and then if I clicked on "Back to record list" I get the short display with the default number of max hits and not the amount I originally specified.

As I see it, the problem is in the fact that in sub html_record the record number is calculated like this:
$record_number = ((($nh - 1) * $db_max_hits) + $rec_count);
It uses $db_max_hits and not the number of hits you originally specified
Also, when you call the long url you make mh=1 and you completely lose the mh you specified in your original search.
The links shown on the short form which were generated in the query in $db_next_hits are based on the original mh of the search. When you use one of those links you get a short form that is calculating record number assuming the default value of mh ($db_max_hits) and this causes all of the links to get confused and not find the correct record.

My solution:
I created a new variable search_mh that holds the mh of the original search and is passed in the $long_url so you do not lose the original mh of the search even though you want to set mh=1 to get the long display.

My changes (outlined below) seem to be be working fine now no matter what number you put in for mh.
With the short/long mod, you do not really need to let people specify a mh other than the default, but if you do, I think this will fix the links.

If anyone knows of any reason my fix might cause problems, please let me know.
Thanks,
Eileen

My changes to the Short/Long Mod
in sub html_record :

replace:
# create link to full display
$record_number = ((($nh - 1) * $db_max_hits) + $rec_count);

with:
my $maxhits_of_this_search;

if ($in{'search_mh'}) {
$maxhits_of_this_search = $in{'search_mh'};
}
elsif ($in{'mh'}){
$maxhits_of_this_search = $in{'mh'};
}
else {
$maxhits_of_this_search = $db_max_hits;
}

# create link to full display
$record_number = ((($nh - 1) * $maxhits_of_this_search) + $rec_count);

___________________________
then replace
$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";
with
$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1&search_mh=$maxhits_of_this_search";
_________________________________
Then in sub html_record_long

replace:
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;

with
$in{'search_mh'} ? ($mh = $in{'search_mh'}) : ($mh = $db_max_hits);
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh&mh=$mh"><$font>Back to record list</font></a>~;