Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Replace Rating whith image

Quote Reply
Replace Rating whith image
Hi,

What's the code to display rating whit image,

I trying this code:

<%if Rating > 9%>
<img src="<%build_root_url%>/img/18.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 8%>
<img src="<%build_root_url%>//img/16.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 7%>
<img src="<%build_root_url%>/img/14.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 6%>
<img src="<%build_root_url%>/img/12.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 5%>
<img src="<%build_root_url%>/img/10.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 4%>
<img src="<%build_root_url%>/img/8.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 3%>
<img src="<%build_root_url%>/img/6.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 2%>
<img src="<%build_root_url%>/img/4.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 1%>
<img src="<%build_root_url%>/img/2.gif" alt="<%Votes%>">
<%endif%>
<%if Rating > 0%>
<img src="<%build_root_url%>/img/1.gif" alt="<%Votes%>">
<%endif%>

But, when i run it
If the vote= 8, he display all the image above
image for rating 7
image for rating 6
...

Can't you tell me what's the solution
Tnank you


Quote Reply
Re: [michelb] Replace Rating whith image In reply to
Try changing every > to >=
Quote Reply
Re: [michelb] Replace Rating whith image In reply to
Hi,

That should look like:

<%if Rating >9%>
<img src="...">
<%elsif Rating > 8%>
<img src="...">
..
<%elsif Rating > 0%>
<img src="..">
<%endif%>

Note the use of elsif instead of separate if tags.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Replace Rating whith image In reply to
Thank you for your post

I have trying, the 2 version, but he display allmost the same image

If the ratin= 8.00, he display all the image above
image for rating 7
image for rating 6
Thank's
Quote Reply
Re: [michelb] Replace Rating whith image In reply to
You need to use the:

<%if ...%>
<%elsif%>
<%elsif%>
<%elsif%>
<%elsif%>
<%elsif%>
<%elsif%>

<%endif%>

Form, so that only ONE value is picked.

Only _one_ <%endif%> and one <%if%> , everything else is <%elseif%>tags.



PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Replace Rating whith image In reply to
Hi,

Thank's for you help

I have this option
In Build - Template global
Create a new global called: rate_img

description:

sub {
my ($rec) = @_;
if ($rec->{'Rating'} eq '10.00') {'20'; }
elsif ($rec->{'Rating'} eq '0.00') {'00'; }
elsif ($rec->{'Rating'} eq '') {'00'; }
elsif ($rec->{'Rating'} le '0.50') {'01'; }
elsif ($rec->{'Rating'} le '1.00') {'02'; }
elsif ($rec->{'Rating'} le '1.50') {'03'; }
elsif ($rec->{'Rating'} le '2.00') {'04'; }
elsif ($rec->{'Rating'} le '2.50') {'05'; }
elsif ($rec->{'Rating'} le '3.00') {'06'; }
elsif ($rec->{'Rating'} le '3.50') {'07'; }
elsif ($rec->{'Rating'} le '4.00') {'08'; }
elsif ($rec->{'Rating'} le '4.50') {'09'; }
elsif ($rec->{'Rating'} le '5.00') {'10'; }
elsif ($rec->{'Rating'} le '5.50') {'11'; }
elsif ($rec->{'Rating'} le '6.00') {'12'; }
elsif ($rec->{'Rating'} le '6.50') {'13'; }
elsif ($rec->{'Rating'} le '7.00') {'14'; }
elsif ($rec->{'Rating'} le '7.50') {'15'; }
elsif ($rec->{'Rating'} le '8.00') {'16'; }
elsif ($rec->{'Rating'} le '8.50') {'17'; }
elsif ($rec->{'Rating'} le '9.00') {'18'; }
elsif ($rec->{'Rating'} le '9.50') {'19'; }
else {'00'; }
}

in links.html

<%body_font%><b>Votes: </b></font>
<%if Rating = 0.00%>
<%error_font%>No vote</font>
<%else%>
<IMG SRC="<%build_root_url%>/img/<%rate_img%>.gif" WIDTH=56 HEIGHT=10 BORDER=0 ALT="<%Rating%>"></A>
<%endif%>

This mode work great

Thank's