On Cabling On Line - www.col.net.au Theming of Table Views Using: Overriding theme functions   Signwriter Module   jTooltips Module   Custom Module By Geoff Davies (gpdinoz) from Behind the Page
Cabling On Line is a Directory of links for the Australian and New Zealand Cabling Industry. People can register and submit information about their products and services with links to their own site for more information. If they want more listings there are 4 levels of paid  sponsorship available. Each type of product or service is listed using a table view with it's filter on a separate page so listing can be searched for relevant entries. Some Drupal Specs 11 Types of users with 5 sponsorship levels => 62 roles 31 Custom Node Types (using CCK)‏ 35 Views It is a work in progress with a custom theme still to come and a lot more explanatory text needed. Introduction
 
 
46 columns wide table  Table Headings running vertical Dots in table with hover tooltips  Filter on separate page Features
Filter on Separate page
Standard Drupal theming
With Custom theming
Overriding theme functions theme_views_view_table (Standard Drupal theming for views tables)  phptemplate_views_view_table (Overrides all view table theming)  phptemplate_views_view_table_Contractors (Overrides only Contractors view table theming)  (Place in template.php)
theme_views_view_table function theme_views_view_table($view, $nodes, $type) { $fields = _views_get_fields(); foreach ($nodes as $node) { $row = array(); foreach ($view->field as $field) { if ($fields[$field['id']]['visible'] !== FALSE) { $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields,  $field, $node, $view); $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; } } $rows[] = $row; } return theme('table', $view->table_header, $rows); }
Overiding the function in template.php function phptemplate_views_view_table_Contractors($view, $nodes, $type) { $fields = _views_get_fields(); foreach ($nodes as $node) { $row = array(); foreach ($view->field as $field) { if ($fields[$field['id']]['visible'] !== FALSE) { switch ($field['field']) { case 'title'; case 'field_contractor_sponsership_value'; case 'field_contractor_website_url'; case 'field_contractor_postcode_value'; $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; break; default :...... cont
Display dots in cell if '1' in database default: $number = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); if ($number ==1) { $number ='<img src=&quot;/media/headings/dot.png&quot; alt=&quot;Y&quot;  title=&quot;'.$field['label'].'&quot; >'; } else { $number =''; } $cell['data'] = $number; $cell['class'] = &quot;view-field &quot;. views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; } } } $rows[] = $row; } . . . . . . . . . .continued, but first introducing the signwriter module
Signwriter Module The Signwriter module allows you to use custom fonts in headings. It does this by replacing html headings with an image generated from a TrueType font file which resides on the server.  It can also be embedded in your theme with the following code $profile = signwriter_load_profile('Theme Heading'); print signwriter_title_convert($title, $profile); I modified the signwriter module to write vertically. A few examples:
 
 
Replacing headers with images using Signwriter module $profile = signwriter_load_profile('ViewHeaders'); $profile->height = 220 ; foreach($view->table_header as $key=>$value){ if ( $key != 1 AND $key != 3){ $text = $view->table_header[$key]['data']; $view->table_header[$key]['data'] = signwriter_title_convert($text, $profile); } } return theme('table', $view->table_header, $rows, $attributes = array('id'=>'Contractors_view')); }
Custom Module Overview This module hides the filter on specific views and creates a separate page where it is displayed as checkboxes and in 4 columns hook_form_alter to hide the filter on the view hook_menu to create paths for each separate “search” page custom function that loads the correct filter and formats it as checkboxes and display them in 4 columns
The End

Advanced Drupal Views: Theming your View

  • 1.
    On Cabling OnLine - www.col.net.au Theming of Table Views Using: Overriding theme functions Signwriter Module jTooltips Module Custom Module By Geoff Davies (gpdinoz) from Behind the Page
  • 2.
    Cabling On Lineis a Directory of links for the Australian and New Zealand Cabling Industry. People can register and submit information about their products and services with links to their own site for more information. If they want more listings there are 4 levels of paid sponsorship available. Each type of product or service is listed using a table view with it's filter on a separate page so listing can be searched for relevant entries. Some Drupal Specs 11 Types of users with 5 sponsorship levels => 62 roles 31 Custom Node Types (using CCK)‏ 35 Views It is a work in progress with a custom theme still to come and a lot more explanatory text needed. Introduction
  • 3.
  • 4.
  • 5.
    46 columns widetable Table Headings running vertical Dots in table with hover tooltips Filter on separate page Features
  • 6.
  • 7.
  • 8.
  • 9.
    Overriding theme functionstheme_views_view_table (Standard Drupal theming for views tables) phptemplate_views_view_table (Overrides all view table theming) phptemplate_views_view_table_Contractors (Overrides only Contractors view table theming) (Place in template.php)
  • 10.
    theme_views_view_table function theme_views_view_table($view,$nodes, $type) { $fields = _views_get_fields(); foreach ($nodes as $node) { $row = array(); foreach ($view->field as $field) { if ($fields[$field['id']]['visible'] !== FALSE) { $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = &quot;view-field &quot;. views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; } } $rows[] = $row; } return theme('table', $view->table_header, $rows); }
  • 11.
    Overiding the functionin template.php function phptemplate_views_view_table_Contractors($view, $nodes, $type) { $fields = _views_get_fields(); foreach ($nodes as $node) { $row = array(); foreach ($view->field as $field) { if ($fields[$field['id']]['visible'] !== FALSE) { switch ($field['field']) { case 'title'; case 'field_contractor_sponsership_value'; case 'field_contractor_website_url'; case 'field_contractor_postcode_value'; $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = &quot;view-field &quot;. views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; break; default :...... cont
  • 12.
    Display dots incell if '1' in database default: $number = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); if ($number ==1) { $number ='<img src=&quot;/media/headings/dot.png&quot; alt=&quot;Y&quot; title=&quot;'.$field['label'].'&quot; >'; } else { $number =''; } $cell['data'] = $number; $cell['class'] = &quot;view-field &quot;. views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; } } } $rows[] = $row; } . . . . . . . . . .continued, but first introducing the signwriter module
  • 13.
    Signwriter Module TheSignwriter module allows you to use custom fonts in headings. It does this by replacing html headings with an image generated from a TrueType font file which resides on the server. It can also be embedded in your theme with the following code $profile = signwriter_load_profile('Theme Heading'); print signwriter_title_convert($title, $profile); I modified the signwriter module to write vertically. A few examples:
  • 14.
  • 15.
  • 16.
    Replacing headers withimages using Signwriter module $profile = signwriter_load_profile('ViewHeaders'); $profile->height = 220 ; foreach($view->table_header as $key=>$value){ if ( $key != 1 AND $key != 3){ $text = $view->table_header[$key]['data']; $view->table_header[$key]['data'] = signwriter_title_convert($text, $profile); } } return theme('table', $view->table_header, $rows, $attributes = array('id'=>'Contractors_view')); }
  • 17.
    Custom Module OverviewThis module hides the filter on specific views and creates a separate page where it is displayed as checkboxes and in 4 columns hook_form_alter to hide the filter on the view hook_menu to create paths for each separate “search” page custom function that loads the correct filter and formats it as checkboxes and display them in 4 columns
  • 18.