Provide an option to hide the SimilarNodes: Weight field, or work without it

joachim - January 8, 2009 - 13:51
Project:Similar Nodes
Version:5.x-1.1
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

The SimilarNodes: Weight field is required to make a view work, but it's ugly -- users have no reason to see a bunch of numbers that are meaningless to them.
It would be good if the module could work without it, but looking at the comments in the code, it seems probably not!

What does work is adding two handlers to the field definition: visible and hidden.

Expand the field definition to this:

          'fields' => array('similar_weight' => array('name' => t('SimlarNodes: Weight'),
                                              'query_handler' => 'similarnodes_sum',                                             
                                              'help' => t('The similarity weight to the provided nid'),
                                              'handler' => array(
                                                'similarnodes_weight_visible' => 'Visible',
                                                'similarnodes_weight_hidden' => 'Hidden',
                                              ),
                                              'sortable' => TRUE)),

and add some handler functions:

function similarnodes_weight_hidden($fieldinfo, $fielddata, $value, $data) {
  // return NOTHING!
  return;
}
function similarnodes_weight_visible($fieldinfo, $fielddata, $value, $data) {
  return check_plain($value);
}

 
 

Drupal is a registered trademark of Dries Buytaert.