I'm trying to add divs around the links that appear at the bottom of comments ("edit", "reply", "post new comment" and so on). I realize that the function that creates these links is not one that can be themed directly, and I do not want to hack the core code as suggested in this thread so am trying to have a go at the suggestion in the last comment in that thread and use the _phptemplate_variables function in my template.php

But, whilst to date I have managed to do some limited over-riding of themable functions I'm not sure I understand what I need to do when changing/adding to the _phptemplate_variables function.

There is already a case 'comment' statement in there which adds some classes to comments but what I am trying to do is add divs around the links so I can tunr them into CSS based buttons. Can anyone shed any light on what I should do?

I'm guessing - completely in the dark, that I would do something like...

$links = $vars['links']
foreach ($links as $link)
$link = "

".$link."

";
return $links

...somewhere in the case "comment' section of that function. Would I be right? Or nearly so?

TIA, Jock

Comments

jockox3@drupal.org’s picture

It stripped the html of course from this:

$links = $vars['links']
foreach ($links as $link)
$link = "whatever html I want here".$link."close whatever html tag";
return $links

andrew_hoffi’s picture

Hi Jockox3,
I just came across your post and wondered if you've managed to come up with anything to theme these links? I've tried to get tags around them and failed. :O(

Dylunio creadigol. Syniadau dwyieithog. • Creative design. Bilingual ideas. www.hoffi.com

Thanks
Andrew
-------------------
www.hoffi.com

jockox3@drupal.org’s picture

I posted before I came out to work this morning so haven't had a chance to put my theory into practice regardless of nobody responding. I'll give it a go this evening and report back.

jockox3@drupal.org’s picture

...in my _phptemplate_variables:

      if ($vars['comment']->links) {
      
      $links = $vars['comment']->links;
      	foreach ($links as $link) {
      		$link = '<div class="button_top"><div class="button_bottom"><div class="button_left"><div class="button_right"><div class="button_top_left"><div class="button_top_right"><div class="button_bottom_left"><div class="button_bottom_right">'.$link.'</div></div></div></div></div></div></div></div>';
      		}
      	$vars['comment']->links = $links;
		}

...but it didn't do anything, so I guess I'm wrong on the variable $vars['comment']->links and don't know where to look next.

jockox3@drupal.org’s picture

It's got nothing to do with trying to theme the comment itself. Justput a general override of the theme_links function in your phptemplate. I followed the api documentation here:

http://api.drupal.org/api/function/theme_links/5

Let me know if you need more info on how to do it - I'm no PHP code-warrior but got it to work.

ajayg’s picture

Do you mind showing some code? How you managed to change only the comments link and nothing else?