[support] custom theming a views field

Fred Jones fredthejonester at gmail.com
Fri Jan 18 08:28:58 UTC 2008


Joe Murray wrote:
> I have a Drupal 5 cck type with a large text field that is not often 
> populated. The column for that field in a view could have a link to view 
> the node, and include the text in the field in a tooltip if it is 
> non-blank, and otherwise not display anything to the user.
> 
> I think to implement this I want to provide custom theming of the field 
> in views that will be invoked by theme_get_function 
> <http://api.drupal.org/api/function/theme_get_function/5>: something 
> along the lines of function tablename_fieldname(). Could anyone point me 
> in the direction of code that does this kind of theming?

Sounds like your view is of type table. To custom theme the content of a 
column use a function template.php like:

function 
phptemplate_views_handle_field_node_data_FIELDNAME_FIELDNAME_value($fields, 
$field, $data)

This works for me anyhow. You may have to play with it to get the 
function name precise. To see this in the Views code, find function 
phptemplate_views_view_table and see the line:

         $cell['data'] = views_theme_field('views_handle_field', 
$field['queryname'], $fields, $field, $node, $view);

See the code in theme_views_handle_field and you will see how the Views 
module looks for custom functions to replace the default ones.

HTH

Fred


More information about the support mailing list