Gossamer Forum
Home : Products : DBMan : Customization :

TopTen.pl display error

Quote Reply
TopTen.pl display error
Dear All

Using Lee's TopTen.pl script to display a counter and a list of top10 searches - All works well except:

When searching by ID number the counter is always displayed as 1.
Any other search criteria e.g. company name, dateofentry, etc. displays the correct value. Opening the counter file shows the correct value and this is displayed if another search field is used.

Any ideas??

Quote Reply
Re: TopTen.pl display error In reply to
I have placed an error handler in sub html_record:

$count_up= "$counter_dir/$rec{$db_key}";
open (COUNT, "<$count_up") or &cgierr("unable to open file $counter_dir/$rec{$db_key}. Reason: $!");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;

This reports 'error opening file <<filename>> - no such file or dir'.
However the file does exist!!

Regards, Brian


Quote Reply
Re: TopTen.pl display error In reply to
It sounds like you might be having the same $db_key error I described in the following thread:

http://gossamer-threads.com/...w=collapsed&sb=5

I'm still completely stumped why it's behaving this way...

Dan

Quote Reply
Re: TopTen.pl display error In reply to
Yep, definitely sounds familiar, but no-one else appears to be interested!!

On my system, Only the Admin can view the top10 searches and this uses a short display. Therefore the counter in not incremented - as expected e.g. sub html_topten:
%rec = (&get_record($toplist));

When normal visitors conduct a search, html_record is called and at the top is:

$count_up= "$counter_dir/$rec{$db_key}";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;

This does the incrementing. This all appears to work fine except if a visitor searches by ID, which equals $db_key from the config file! Then I get a cgi error saying the counter file doesn't exist...

The only part of the topten mod I do not understand is:
# Everyone will also need to delete (or comment out) the following
# line in sub get_record in the db.cgi script:
($restricted = 1) if ($auth_modify_own and !$per_admin);

Apart from that I can not understand how such a simple Mod can course such a problem!

BTW, I changed
$count_up= "$counter_dir/$rec{$db_key}";
to:
$count_up= "$counter_dir/$rec{ID}";

with no effect...

Can anyone help??

Best regards, Brian


Quote Reply
Re: TopTen.pl display error In reply to
Definitely the same problem... What bugs me is that I don't think this is specific to the Top 10 mod. It appears to be something related to DBMan in general or the Short/Long mod (or possibly some strange combination of mods) that only is becoming apparent when used in such a manner. For whatever reason, ID carries no value in the Long display depending on how the Long display was arrived at, even though every other field value shows up.

Dan

Quote Reply
Re: TopTen.pl display error In reply to
Hi Dan

It would make sense it is related to DBMan as the mod if so simple!

I am not sure what you mean with your last sentence. My link from the (short) Top10 listing to display the long listing works OK. That is, only a single record id displayed with the correct ID - just wrong counter. The counter file, it can not find, is of course the ID number of the record and the error message reports the 'missing' filename correctly!

If you post to me off list, I will give you access - if its helps.

Regards, Brian

Quote Reply
Re: TopTen.pl display error In reply to
Aha, I think I just figured it out!!! In certain situations, such as List All, $rec{'ID'} is made bold. Thus, I'm guessing it is trying to open a file with the bold tags wrapped around the file number.

It would be preferable to keep search results bolded, but not the ID field. I'll have to see if there's a simple way to work around that.

Progress...

Dan

Quote Reply
Re: TopTen.pl display error In reply to
Success! Smile Here's what I used where I want to open/update the counter file (in the Long display):

$rec{'ID'} =~ s/<\/?B>//g; # remove bold ID search results tags
$count_up= "$counter_dir/$rec{'ID'}";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup 1;
print COUNT $countup2;
close COUNT;


Works like a charm.

Dan

Quote Reply
Re: TopTen.pl display error In reply to
Bingo!! You are right....In the cfg file, set
$db_bold = 0;

and things start to work. Perhaps we should start this as a new thread so JPD et al can have a look - I get the feeling they don't want to get involved with MODS.

Best regards, Brian

Quote Reply
Re: TopTen.pl display error In reply to
That method works, but I prefer to keep $db_bold set to 1, as it seems intuitive to have the search results bold. No reason to have the ID field bold though, unless you want people searching on it.

I think Carol has just been absent from the forum for a few weeks. I doubt there's any unwillingness to get involved with mods. That would be very much unlike the DBMan community.

Dan

Quote Reply
Re: TopTen.pl display error In reply to
I agree with bolding the results - only the admin here can search by record ID so it is no big deal for me to leave it as it was, but I am fussy - I hate loose ends.

I am sure we can sort this between us. Will keep you posted...

Best regards, Brian

Quote Reply
Re: TopTen.pl display error In reply to
You beat me to it Smile, I have:

## Added by BC for Top10 28/9/00
if ($per_del){
$rec_bc = $rec{ID};
$rec_bc =~ s/<\/?b>//ig;
}

$count_up= "$counter_dir/$rec_bc";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;

The only difference is that the results can still be bolded

Best regards, Brian

Quote Reply
Re: TopTen.pl display error In reply to
Why would you ever want the ID bold in search results? If that's what you're searching on, it's going to be pretty obvious if you found it. If the user does not have delete permission, you're still going to have the problem of the following line not working:

$count_up= "$counter_dir/$rec_bc";

unless you are defining it elsewhere.

Dan

Quote Reply
Re: TopTen.pl display error In reply to
I just wanted the bold part left in Smile.

Only the administrator ($per_del) can search the ID field - though they are not a full administrator i.e. not ($per_admin).

Best regards, Brian

Quote Reply
Re: TopTen.pl display error In reply to
Still, unless I'm misunderstanding you... Searching on the ID field is not the sole issue. A "List All" search effectively searches the ID field, so anyone can access pages that would bold the ID. Unless your counter use is very different than what I'm envisioning, you will still have the problem with bold IDs messing up the counter path.

Am I missing something?

Dan

Quote Reply
Re: TopTen.pl display error In reply to
You Are right... I had to change to if ($per_view).

Best regards, Brian

Quote Reply
Re: TopTen.pl display error In reply to
Ok, now we're headed the same direction... Smile Still, it seems you're holding onto the bolded ID field for some reason. Do you have anyone that would not have view permissions? If not, it's a trivial distinction and you might as well remove the bold tags in all instances.

Dan

Quote Reply
Re: TopTen.pl display error In reply to
yeah true... I just want the admin to notice the difference between record ID's 38, 383, 3833 etc. if they search by this field. Ideally using the ID field would set ww=1. That's my next mod...

Anyhow if you are interested the site in question is http://Sussexfind.co.uk

Best regards, Brian