hello,

can anyone help me how to manually code and add element's into $links variable in node.tpl.php? for example i have "comment", "read more" links... and i wanted to add another link "print". how do i accomplished this?

thanks,

vsotto

Comments

gevacril’s picture

If just adding the print link is the issue, try the print module.

vrsotto’s picture

thanks for reply... but, what i mean is to add/insert element as many as i want into $links variable... "print" is just an example to be added in $links variable...

gausarts’s picture

This is what I did in case you don't need a module:

function yourtheme_preprocess_node(&$vars, $hook) {
    //This will add quick admin links such as edit and Delete along node display
    //Original code from http://11heaven.com
    // If we are in teaser view and have administer nodes permission
  if (user_access('administer nodes')) {
    // get the human-readable name for the content type of the node
    //$content_type_name = node_get_types('name', $vars['node']);
    // making a back-up of the old node links...
    $links = $vars['node']->links;
    $nid = $vars['node']->nid;
    $links['quick-edit'] = array(
      'title' => 'Edit',
      'href' => 'node/' . $nid . '/edit',
      'query' => drupal_get_destination(),
    );
    // and then adding the quick delete link
    $links['quick-delete'] = array(
      'title' => 'Delete',
      'href' => 'node/' . $nid . '/delete',
      'query' => drupal_get_destination(),
    );
	$vars['links'] = theme('links', $links, array('class' => 'links inline'));
  }
}

Add more and check the permission as well.

love, light n laughter

vrsotto’s picture

thanks... ill try to work on this... :)

vrsotto’s picture

by the way... how do i use this $content_type_name = node_get_types('name', $vars['node']);?

vrsotto’s picture

works great... but, how do i put some icon to each links? :)