You are here

function draggableviews_handler_fieldapi::get in DraggableViews 7

Same name and namespace in other branches
  1. 7.2 handlers/draggableviews_handler_fieldapi.inc \draggableviews_handler_fieldapi::get()

Returns the field value of the given node. Usually this is used to get the weight and the parent id.

The expected field (weight or parent) has to be set in $this->field;

Parameters

int $value node id:

Return value

int

Overrides draggableviews_handler::get

File

implementations/draggableviews_handler_fieldapi.inc, line 62
The default implementation for draggableviews.

Class

draggableviews_handler_fieldapi

Code

function get($value) {

  // Get the field name
  $field_name = $this->field->table . "_" . $this->field->real_field;

  // Views allows only 60 chars for the field name
  if (strlen($field_name) > 60) {
    $field_name = substr($field_name, 0, 60);
  }

  // Search for the nid and return the value from of the Views result
  foreach ($this->view->result as $result) {
    if ($result->nid == $value) {
      return empty($result->{$field_name}) ? 0 : $result->{$field_name};
    }
  }
  return 0;
}