Gossamer Forum
Home : Products : Links 2.0 : Customization :

At Wits End: Simple Mod of Variable Rating Image Won't Work

Quote Reply
At Wits End: Simple Mod of Variable Rating Image Won't Work
Hello, all. I was hoping that someone could help me solve this problem,
because I'm at wits end. I have copyed the code from the variable rating
image mod and made the following changes:

Code:
IN site_html_templates.pl, sub site_html_link

my %rec = @_;
my $cost_img = "";
$cost_01 = qq|<IMG SRC="/img/icon/1.gif" WIDTH=11 HEIGHT=16 ALT="Entry Fee: $rec{'FeeEntry'}, Est. Fully Loaded Cost: $rec{'FeeLoaded'}" BORDER="0" ALIGN="ABSMIDDLE">|;
$cost_02 = qq|<IMG SRC="/img/icon/2.gif" WIDTH=11 HEIGHT=16 ALT="Entry Fee: $rec{'FeeEntry'}, Est. Fully Loaded Cost: $rec{'FeeLoaded'}" BORDER="0" ALIGN="ABSMIDDLE">|;
$cost_03 = qq|<IMG SRC="/img/icon/3.gif" WIDTH=11 HEIGHT=16 ALT="Entry Fee: $rec{'FeeEntry'}, Est. Fully Loaded Cost: $rec{'FeeLoaded'}" BORDER="0" ALIGN="ABSMIDDLE">|;
$cost_04 = qq|<IMG SRC="/img/icon/4.gif" WIDTH=11 HEIGHT=16 ALT="Entry Fee: $rec{'FeeEntry'}, Est. Fully Loaded Cost: $rec{'FeeLoaded'}" BORDER="0" ALIGN="ABSMIDDLE">|;
$cost_05 = qq|<IMG SRC="/img/icon/5.gif" WIDTH=11 HEIGHT=16 ALT="Entry Fee: $rec{'FeeEntry'}, Est. Fully Loaded Cost: $rec{'FeeLoaded'}" BORDER="0" ALIGN="ABSMIDDLE">|;

if ($rec{'FeeLoaded'} eq '0') { $cost_img = $cost_01; }
elsif ($rec{'FeeLoaded'} le '25') { $cost_img = $cost_01; }
elsif ($rec{'FeeLoaded'} le '50') { $cost_img = $cost_02; }
elsif ($rec{'FeeLoaded'} le '75') { $cost_img = $cost_03; }
elsif ($rec{'FeeLoaded'} le '100') { $cost_img = $cost_04; }
else { $cost_img = $cost_05; }

return &load_template ('link.html', {
detailed_url => "$build_detail_url/$rec{'ID'}$build_extension",
cost_img => $cost_img,
%rec,
%globals
});
}

The problem is that $cost_05 never gets called, no matter how big
FeeEntry is over 100. Yet, I know the values are working because 1) FeeEntry
is calculated, and 2) if I set the first if line to eq '125' ... $cost_05,
it will indeed return $cost_05 for links with 125. It should work, it
doesn't, and I can't for the life of me figure out why. Help?

[This message has been edited by oldmoney (edited August 18, 1999).]
Quote Reply
Re: At Wits End: Simple Mod of Variable Rating Image Won't Work In reply to
One suggestion on mods...Install the mod in its AS IS condition, then make modifications to it. This is great advice past on to me from JPDeni, the moderator of the DBMAN Forums.

Anyway, what I did to use only five images for the Image Rating Scale Mod is to identify images with levels of rating. For instance, I associated $rate_01 through $rate_07 variables with a two star image, and $rate_08 through $rate_12 with a three star image, and so on and so on. Then in the "Rating", which you have "FreeLoaded" section, I kept it the same.

All the stars show up with their appropriate rating.

Try associating your $cost_* variables with images 1 - 5. I think that the problem you have is associating the FreeLoaded variable with the incremental values that do not show up properly. Try to stick as close to the original mod and it may work.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: At Wits End: Simple Mod of Variable Rating Image Won't Work In reply to
Thanks for the advice. Actually, I have the original variable rating
image mod working perfectly as well. What is specifically not working
is that all values of FeeLoaded greater than 100 never gets associated
with $cost_05, while the rest (<=25 = $cost_01, <=50 = $cost_02, ...)
works fine.

[This message has been edited by oldmoney (edited August 18, 1999).]
Quote Reply
Re: At Wits End: Simple Mod of Variable Rating Image Won't Work In reply to
you can use my rating image mod..

this is modded for you.. put it at the end of your site_html_templates.pl (above the 1:

Code:
sub get_cost_image {
my ($cost) = @_;
my ($i, $image);

for ($i = 1; $i <= 5; $i++) {
$image = qq~<img src="/img/icon/$i.gif" width="11" height="16" alt="Entry Fee: $cost" border="0">~ and last if ($cost <= $i*25);
}

return $image or $cost;
}

what you do..

Code:
cost_img => &get_cost_image($rec{'FeeLoaded'}),

when the template loads..

that's all! Smile

[This message has been edited by widgetz (edited August 18, 1999).]

[This message has been edited by widgetz (edited August 18, 1999).]
Quote Reply
Re: At Wits End: Simple Mod of Variable Rating Image Won't Work In reply to
Geez! OK, this is as simple as evaluating strings versus numbers. The way the
original variable rating image was written evaluated strings, but since the
field I modified is not as "fixed", it blows up. For example, le "125" as a
string comes *before* 20. The correct method would be:
Code:
elsif ($rec{'FeeLoaded'} <= 25... etc.
... and all is well. BTW Widgetz, your loop to construct the variables is smart,
and I will change that throughout both this and the variable image mod.

[This message has been edited by oldmoney (edited August 18, 1999).]
Quote Reply
Re: At Wits End: Simple Mod of Variable Rating Image Won't Work In reply to
hehe.. yea that's right old monkey.. le is for strings.. hehe Smile

i learned that just awhile ago when i discovered all my numbers were sorted wrong in a program.. hehe

jerry