How do I theme comment links in Drupal? -


i want theme "add comment" , "comments" links shown on node has comments enabled. know there's theme() , theme_links() can this, i'm not sure how use them. i'm pretty sure want theme_links(), since i'm after links in case. how comment links specifically? don't want theme links, ones on comments. if helps, goal add image next each of these links. also, next "comments" want include number of comments posted.

to clarify, want theme links appear on node, not links appear on comments themselves.

to add image/icon link, can use simple css. css add icon "add comment" link, same done other links (li.comment_delete, li.comment_edit, etc).

ul.links > li.comment_add > {   background: url(path image) no-repeat;   padding-left: 20px;  /* change compensate size of image */ } 

to add number of comments on node can use function comment_num_all($node->nid). instance if add number of comments "add comment" link, add hidden div node.tpl.php (or each content type template) , jquery edit link text:

<div id="num-comments" style="display:none;"><?php print comment_num_all($node->nid); ?></div> 

jquery:

$('ul.links > li.comment_add > a').text('add new comment (' + $('#num-comments').text() + ')'); 

this not elegant solution, works. if want use theme_links() think have create custom module.

edit: option create custom module. not use theme_links(), hook_link_alter() instead. small example module change title of "add new comment" link, add icon , include number of current comments attached node: (replace every instance of mymodule_name name choose module)

step 1: create file called mymodule_name.info , add:

name = "mymodule_name" description = "change appearance of links appear on nodes" core = 6.x 

step 2: create file called mymodule_name.module , add:

<?php    /**    * implementation of hook_link_alter    */   function mymodule_name_link_alter(&$links, $node){     if (!empty($links['comment_add'])) {       // number of comments node       $num_comments = db_result(db_query('         select comment_count          {node_comment_statistics}          nid = %d       ', $node->nid));        // set "add new comment" link text       $links['comment_add']['title'] = '<img src="path icon"/> add comment text (' . $num_comments . ')';        // allow html in link text       $links['comment_add']['html'] = true;     }   } 

step 3: put these files in folder called mymodule_name, place folder in sites/all/modules, , enable module

edit: find array keys: in node.tpl.php (or other node template) can add <?php print_r($node->links); ?>. show of link info displayed in node, , keys of main array use in module. can try using firebug/chrome dev tools, etc @ class of list item containing link (ie ul.links > li.comment_add). believe when links constructed, drupal uses array key class link.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -