1

I have the following piece of code:

l('<div class="magnifier gradient"></div>' . $image, $link_path, array('html' => TRUE, 'attributes' => $attributes))

Which creates a nice link, as it should be. Now I want to add a rel-attribute without getting rid off $attributes (because I need that one). I have Googled and tried a lot, but nothing seems to work. So if anyone can help me with just adding a rel-attribute without deleting the other attributes, I would be grateful!

Thanks

1 Answer 1

2

If I understand you right you just want to add the rel attribute to the $attributes array before you call l(). Something like this:

$attributes['rel'] = 'the_rel';
print l('<div class="magnifier gradient"></div>' . $image, $link_path, array('html' => TRUE, 'attributes' => $attributes));

That will add the an item to the $attributes array with a key of rel and a value of the_rel, and won't affect any of the other attributes already in the array.

0

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.