I am using views(table) on the frontpage. If I mark the node as sticky it works and appears on the top of the list but there is no way to distinguish it is there any way to theme sticky node titles on views table. I would appreciate all feed backs.

Thanks

Comments

werushka’s picture

up

dawehner’s picture

Status: Active » Fixed

you could achive this using

<?php
/**
 * Display the nodes of a view as a table.
 */
function phptemplate_views_view_table_VIEWNAME($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);
}
?>

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

laken’s picture

The example above shows the theme function for where to add a sticky class to views table rows, but doesn't actually show how to do it. Here's what worked for me:

In the function above, replace the line $rows[] = $row; with this block:

    if ($node->node_sticky) {
      $rows[] = array('data' => $row, 'class' => 'sticky');
    }
    else {
      $rows[] = $row;
    }

jarea’s picture

In which file / directory is the code for #2 and #4 placed?

laken’s picture

This would usually go in the template.php file in your theme directory. What you're doing is setting up a theme override for when your view of type table.

By the way, AFIAK this is for Views 1 for Drupal 5 only.

jarea’s picture

By the way, AFIAK this is for Views 1 for Drupal 5 only.

Thanks for the heads up.