Re: Re: Re: Re: The RiffTrax Store

Posts: 1293
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

This was easy. I just created a new Select list field in CCK, and then in my product template (Using the Contemplate module) I put a switch conditional in there:

<?php
<div id="region-codes">
  <?
php
switch (ereg("NTSC", $node->content['field_region_codes']['#value'])) {
default:
  echo
"<div id=\"region-img-off\">";
  break;
case
TRUE:
  echo
"<div id=\"region-img-on\">";
  break;
}
?>

<img src="/<?php print path_to_theme(); ?>/images/region-ntsc.gif"></div>

<?php
switch (ereg("PAL", $node->content['field_region_codes']['#value'])) {

default:
  echo
"<div id=\"region-img-off\">";
  break;
case
TRUE:
  echo
"<div id=\"region-img-on\">";
  break;
}
?>


<img src="/<?php print path_to_theme(); ?>/images/region-pal.gif"</div>

So what it's doing is, no matter what it's showing the images, but I setup CSS to set the opacity for the image to 70% if the div's id is "region-img-off" (which is what the div id becomes unless it finds that particular field in the CCK select element, in which case, the conditional returns TRUE).

Other things to notice: I created an image for each Region - region-pal.gif, region-ntsc.gif, etc. Secondly, the ereg function I used to check my CCK field, which I called "field_region_codes"... the CCK part is important because this will need to refer to whatever you call your select list, if that's the route you take. Mine was just the "key" was the same as the "element", i.e.:

ntsc|NTSC
pal|PAL
riff|RIFF

So you could use those two switch blocks as a starting point, and modify your code to your needs. Let me know if you have any other questions. (The CSS is important too, you'll want to make sure your widths and floats/positioning are all correct so you have the images showing up where they need to go!)

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com