upload_node_links

Versions
7
upload_node_links($node, $build_mode)

Inject links into $node for attachments.

Code

modules/upload/upload.module, line 58

<?php
function upload_node_links($node, $build_mode) {
  $links = array();

  // Display a link with the number of attachments
  $num_files = 0;
  foreach ($node->files as $file) {
    if ((object)$file->list) {
      $num_files++;
    }
  }
  if ($num_files) {
    $links['upload_attachments'] = array(
      'title' => format_plural($num_files, '1 attachment', '@count attachments'),
      'href' => "node/$node->nid",
      'attributes' => array('title' => t('Read full article to view attachments.')),
      'fragment' => 'attachments'
    );
    $node->content['links']['upload_attachments'] = array(
      '#theme' => 'links',
      '#links' => $links,
      '#attributes' => array('class' => array('links', 'inline')),
    );
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.