I'm in my sub theme's comment.tpl.php, and I have print render($content['links']) - how do I access the individual links within that? I tried doing a print_r to see if it was a bunch of nested arrays - it appears it is(?) - but I can't seem to dig into those arrays to get the individual links? I tried $content['links']['comment']['#links']['comment-reply'] for example (based on the structure returned form the print_r) to get just the reply link, but I get nothing.

Ultimately what I'm trying to do: Due to various modules and some flags I have 5 links on every comment: reply, delete, edit, flag, and like. I want to group edit, delete, and flag (and any other future miscellaneous) into a little dropdown menu at the top of the comment. Then put reply and like in individual styled buttons at the bottom. I was planning to just handle the menu and buttons using Bootstrap since that's my theme base, but I can't "get to" the individual links to add the classes and markup I need. Additionally I want to change the displayed text, capitalize Reply for example and add some inline icons for edit, delete, etc.

I've come across theme_links, but that page is over my head. Sounds like maybe I need to understand this? If so I don't even understand where to start to apply it - I searched across all files in my base theme (Bootstrap) and found nothing with that name to start from?

Where and how should I be trying to do all this?

  • I have a similar problem, but thanks to point me toward theme_link function. Anyway, inspecting the $....['comment-reply'], i was able to access the title and href of each links. I don't know why you can't.
    – Astrayus
    Jun 15, 2014 at 12:04

1 Answer 1


thanks to your link to the theme_links i managed to solve my problems, so here's how i would solve yours.

the idea is to split the links in two parts, one to print before and the other after the content.

$group = $content['links']['comment']['#links'];
$plain = array();

if( isset($group['comment-like']))
    $plain['comment-like'] = $group['comment-like'];
if( isset($group['comment-reply']))
    $plain['comment-reply'] = $group['comment-reply'];

$first = $content['links'];
$first['links']['comment']['#links'] = $group;
$second = $content['links'];
$second['links']['comment']['#links'] = $plain;

//before the print render( $content);
//note: apparently, you can't add a class to the <ul> element from here, so you should manually wrap it and fix your css accordingly
print '<wrapp class="something">'.render($first).'</wrapp>';

print render($second);
  • Add this to your comment.tpl.php, probably there's a more "drupal-like" solution, but so far i can't find it.
    – Astrayus
    Jun 15, 2014 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.