Hi,

I'm having a problem in which I'm trying to change a text "delete" link being printed with views into an image (link). I've located the code responsible for the output of the text delete link-

if (node_access('delete', $data)) {
$link_text = $fielddata['options'] ? $fielddata['options'] : t('Delete');
return l($link_text, "node/$data->nid/delete", NULL, drupal_get_destination());
}

and I changed it to:

if (node_access('delete', $data)) {
$img_path = ("/sites/all/themes/BDC/success.png");
$link_text = theme_image("$img_path");
return l($link_text, "node/$data->nid/delete", array(), drupal_get_destination(), NULL, NULL, FALSE, TRUE);
}

Still nothing. I've also tried a number of other code changes, all with the same result. Nothing being outputted at all.

What am I doing wrong?

Jon.

Comments

baronmunchowsen’s picture

Don't know if this is helpful or not, but you can theme your view (and fields within a view) through your theme template.php file I believe. There is some documentation here: http://drupal.org/node/42597 . Could be a good place to have a look.

JonGirard-1’s picture

hmm, I already have something simillar in my template.php file:

<?php
theme('image', $img_path);
?>

which doesn't really seem to do the trick.. so I'm thinking it's all in the code.. just one or two lines incorrect..

Jon.

baronmunchowsen’s picture

Another option would be to alter the appearance of the link using CSS.

You could display the link as a block (display:block) add the image as a background image (background: url(images/some_icon.gif') no-repeat left center) add height (height: 20px) overflow (overflow: hidden) and then padding to push the text below the bottom boundary of the link (padding-top: 30px).

Not sure if this makes sense and in a bit of a hurry to write a whole description - but let me know if this works for you or is an option.

JonGirard-1’s picture

hmm, well that adds the image but even if I push the link down doesn't seem to cause the image to become the link..

Good suggestion though, thanks.

Jon.

baronmunchowsen’s picture

Hummm, are you applying the styles to the link ( <a></a>) tag in your css? If you want, post the source and the css and I'll see if I can help at all.

JonGirard-1’s picture

ah, thanks so much.. I didn't have the "a" added to the end of the tag.. works great now.

I don't think it'll matter if it's not hard coded into the file and only being masked with CSS, do you?

Thanks for your help to the end of the problem. Truly appreciated.

Jon.

baronmunchowsen’s picture

No I think in instances like this CSS is a better solution. You won't run into any upgrade problems should the ever arise. Much lighter-weight in terms of coding also. Glad I could be of assistance.