Hi,
Someone I know needed an image for rating mod and as the "Amazon Fix" one didn't seem to work then I made my own.
So thought I'd share the code with you (the person I wrote it for doesn't mind).
It may not be the shortest or prettiest mod but it works and that is what mattters.
In site_html_templates.pl replace sub site_html_link with:
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rec = @_;
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '5' if ($rec{'Rating'} =~ /(9|10)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '4' if ($rec{'Rating'} =~ /(7|8)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '3' if ($rec{'Rating'} =~ /(5|6)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '2' if ($rec{'Rating'} =~ /(3|4)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '1' if ($rec{'Rating'} =~ /(1|2)\.\d\d/);
$rating = qq|<small>No Rating</small>| if ($rec{'Rating'} =~ /0\.\d\d/);
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
rate_img => $rating,
%rec,
%globals
});
}Then add <%rate_img%> in link.html
You can obviously change the img tag to point to wherever you have the image.
You only need one image that could be a star or whatever.
The mod will duplicate the img tag automatically to show the correct number of stars.
Alternatively you can remove the x '5', x '4', x '3', x '2', x '1' from the variable and use an image that contains all the stars.
So you'd use something like:
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rec = @_;
$rating = qq|<img src="$build_root_url/images/5stars.gif">| if ($rec{'Rating'} =~ /(9|10)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/4stars.gif">| if ($rec{'Rating'} =~ /(7|8)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/3stars.gif">| if ($rec{'Rating'} =~ /(5|6)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/2stars.gif">| if ($rec{'Rating'} =~ /(3|4)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/1stars.gif">| if ($rec{'Rating'} =~ /(1|2)\.\d\d/);
$rating = qq|<small>No Rating</small>| if ($rec{'Rating'} =~ /0\.\d\d/);
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
rate_img => $rating,
%rec,
%globals
});
}Hope I made sense then - if not just ask away...
Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/
Someone I know needed an image for rating mod and as the "Amazon Fix" one didn't seem to work then I made my own.
So thought I'd share the code with you (the person I wrote it for doesn't mind).
It may not be the shortest or prettiest mod but it works and that is what mattters.
In site_html_templates.pl replace sub site_html_link with:
Code:
sub site_html_link { # --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rec = @_;
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '5' if ($rec{'Rating'} =~ /(9|10)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '4' if ($rec{'Rating'} =~ /(7|8)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '3' if ($rec{'Rating'} =~ /(5|6)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '2' if ($rec{'Rating'} =~ /(3|4)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '1' if ($rec{'Rating'} =~ /(1|2)\.\d\d/);
$rating = qq|<small>No Rating</small>| if ($rec{'Rating'} =~ /0\.\d\d/);
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
rate_img => $rating,
%rec,
%globals
});
}
You can obviously change the img tag to point to wherever you have the image.
You only need one image that could be a star or whatever.
The mod will duplicate the img tag automatically to show the correct number of stars.
Alternatively you can remove the x '5', x '4', x '3', x '2', x '1' from the variable and use an image that contains all the stars.
So you'd use something like:
Code:
sub site_html_link { # --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rec = @_;
$rating = qq|<img src="$build_root_url/images/5stars.gif">| if ($rec{'Rating'} =~ /(9|10)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/4stars.gif">| if ($rec{'Rating'} =~ /(7|8)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/3stars.gif">| if ($rec{'Rating'} =~ /(5|6)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/2stars.gif">| if ($rec{'Rating'} =~ /(3|4)\.\d\d/);
$rating = qq|<img src="$build_root_url/images/1stars.gif">| if ($rec{'Rating'} =~ /(1|2)\.\d\d/);
$rating = qq|<small>No Rating</small>| if ($rec{'Rating'} =~ /0\.\d\d/);
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
rate_img => $rating,
%rec,
%globals
});
}
Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/