I have a seleciton list in CCK:

temp|Temporary
full|Full

I want to output the Temporary one. How?

foreach ((array) $node->field_job_length as $item) {
$job[] = $item['view'];
}

This only gets me the temp.

Help

Comments

yched’s picture

Where are you using this code ? in a node template ?
If your display is using the default formatter, you *should* get the aliased values...

billnbell’s picture

I am doing it in a custom template: -search-result.tpl.php

It always returns "temp". I got the Temporary to output by doing the following.

tpl.php:
$job = array();
foreach ((array) $node->field_job_length as $item) {
$job[] = content_format("field_job_length", $item);
}
$hrs = array();
foreach ((array) $node->field_job_hours as $item) {
$hrs[] = content_format("field_job_hours", $item);
}

print implode(",", $hrs) . ' - ' . implode(",", $job);

My theme() call: $output .= theme('hiho_search_result', $node, $row['distance'], 0.0, $links, new content_profile_theme_variables($node->uid));

billnbell’s picture

yched: I guess most people have selection lists that have the same name and value.

|

content_format("field_job_hours", $item);

Is definately the way to get it to work.... FYI for others.