By CMatters on
I have a field within a CCK content type that I want to wrap an <A> tag around. I found the following this post which was a lot of help. This is the code I put the in the template.php.
function theme_views_view_table_listings($view, $nodes, $type) {
$fields = _views_get_fields();
foreach ($nodes as $node) {
$row = array();
$show_href ='';
foreach ($view->field as $field) {
if ($fields[$field['id']]['visible'] !== FALSE) {
switch ($field['field']) {
case 'field_node_title':
$cell['data'] .= '<a href="/listings/details/'.$field_node_title. '">';
$cell['data'] .= views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
$cell['data'] .= '</a>';
break;
}
}
}
$row[] = $cell;
$rows[] = $row;
}
return theme('table', $header, $rows, array('class' => 'show-table'));
}
?>
The pages starts to render but does not finish. It renders the page title, description and usual blocks but stops there. In the rendered HTML I find empty TBODY tags where the table should be. I am a noob (on day three of working with Drupal) so it's probably a bone head mistakes. Ideas?
Thanks,
Lowell
Comments
Still no luck..
So I finally gave up on the above function. Since I only wanted to modify one field, I am going to try to override just that field. Here is the sample function that the Views Theme wizard gave me...
So I am trying to add to this function but having a little difficulty figuring out what all the variables are and what exactly this function is trying to do. There is no documentation of this in the Views docs. I think the part that has me perplexed is that there are 3 return statements.
I would appreciate it if anyone can point me in the right direction. Where, exactly, would I insert my code? Again, I'm a noob. Thanks for the patience.
Thanks.
Got it!
After some experimentation, I got this code to work. It's been awhile since I've played with PHP. Amazing how much you forget. Thanks!