new to drupal and cck (and php), found a nice tutorial on how to theme the cck output for drupal 5. I tried applying it to my D6 site with cck 6.1 march 20 build but I cant get it to work. It is supposed to replace a certain result by a picture but just defaults to the last "else" statement as if the result wasnt found.
If i remove the ['view'] from the sample code (see below) it works fine but prints the picture 2 times even when i set my cck field to hidden trough the admin interface. What do i have to add or change to get rid of that double output?
//Iterates through each item in the field and returns it in the variable $item
foreach ($field_esrb_rating[0] as $item) {
//Retrieves the correct game rating image based on what the rating is
if ($item['view'] == 'EC') { <img src="http://www.esrb.org/images/ratingsymbol_ec.gif" alt="Early Childhood" />
} elseif ($item['view'] == 'E') {
<img src="http://www.esrb.org/images/ratingsymbol_e.gif" alt="Everyone" />
} else {
<img src="http://www.esrb.org/images/ratingsymbol_rp.gif" alt="Rating Pending" />
<?php }
on a side note, i guess ['view'] is some kind of variable? How could i find out what variables are available to use? I waded through the cck php-files in the modules directory but my limited experience brought up nothing. is there a list somewhere?
kind regards
Comments
Comment #1
yched commentedThe code below would probably be more correct :
$field_FIELD_NAME is an array of 'items' (the values - possibly several if the field is multiple).
Each item holds the raw (unsanitized for display) value (often in 'value', but the actual keys depend on the field type), and the 'view' key with the sanitized, formatted value to print out.
Comment #2
yched commentedActually, there was a problem with the 'view' element in node templates. Should be fixed now (except for nodes in fieldgroups, that I'll fix tomorrow)
Comment #3
yched commentedBTW : assigning an issue to yourself means you intend to tackle it yourself :-)
Comment #4
Yoda99 commentedyeah not very smart assigning it to myself *8-)
Still getting used to all these issue queues, bug reports, components, versions... easy to be overwhelmed. Thx for helping out though :)
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.