You are here

function nodeorder_add_links in Node Order 7

Adds links to move node up or down in term.

Parameters

object $node: Current node object.

object $term: Node's term object.

1 call to nodeorder_add_links()
nodeorder_node_view in ./nodeorder.module
Implements hook_node_view().

File

./nodeorder.module, line 300
Nodeorder module.

Code

function nodeorder_add_links(&$node, $term) {
  $weights = nodeorder_get_term_min_max($term->tid);
  $weight = db_select('taxonomy_index', 'ti')
    ->fields('ti', array(
    'weight',
  ))
    ->condition('nid', $node->nid)
    ->condition('tid', $term->tid)
    ->execute()
    ->fetchField();
  if ($weight > $weights['min']) {
    $node->content['links']['nodeorder_move_up_' . $term->tid] = array(
      '#weight' => 10,
      '#theme' => 'link',
      '#path' => 'nodeorder/moveup/' . $node->nid . '/' . $term->tid,
      '#text' => t('Move up in ' . $term->name),
      '#options' => array(
        'query' => drupal_get_destination(),
        'attributes' => array(
          'title' => t('Move this ' . $node->type . ' up in its category.'),
        ),
        'html' => FALSE,
      ),
    );
  }
  if ($weight < $weights['max']) {
    $node->content['links']['nodeorder_move_down_' . $term->tid] = array(
      '#weight' => 10,
      '#theme' => 'link',
      '#path' => 'nodeorder/movedown/' . $node->nid . '/' . $term->tid,
      '#text' => t('Move down in ' . $term->name),
      '#options' => array(
        'query' => drupal_get_destination(),
        'attributes' => array(
          'title' => t('Move this ' . $node->type . ' down in its category.'),
        ),
        'html' => FALSE,
      ),
    );
  }
}