eZ Community » Forums » Setup & design » Custom attribute for <link> tag with...
expandshrink

Custom attribute for <link> tag with image.tpl

Custom attribute for <link> tag with image.tpl

Monday 21 November 2011 5:36:08 pm - 2 replies

Hi guys!

I have defined a custom attribute in content.ini for the "link" xml tag. The attribute is called "rel", so I could set "rel='nofollow'" to a link. I wrote an override for default link.tpl and added custom attribute to the output generation. Works fine, as long as a link is applied to a string only.

However, when a <link> is applied to an image in xml content attribute, the <a> tag is rendered by image.tpl rather than by link.tpl. In default image.tpl (design/base/override/templates/embed/image.tpl), $link_parameters contains all link related settings for the image to render. attribute('show') says, there is an attribute known, called "custom:rel". How can I call this attribute in the template? {$link_parameters.custom:rel} does not work.

Any help is highly appreciated.

Best regards

DonRonaldo.

Monday 21 November 2011 8:43:47 pm

Hi, have you tried this?

{$link_parameters['custom:rel']}

Tuesday 22 November 2011 8:07:56 pm

Brilliant Peter!

 

Thank you for sharing this very helpful alternative syntax for using array keys within eZ Templates.

Your answer will really help Don as he has been looking for this answer for several days in #ezpublish irc

 

I had forgotten about the above syntax solution, I mean in the back of my mind I knew there was another way to get to the contents of the variable but I could not remember exactly what it was. Now that you remind both of us, it makes perfect sense. Here's hoping I remember this next time someone asks for this solution.

 

Best wishes ...

 

Cheers,

//kracker

 

Theme song: K.Flay - I Stopped Caring in '96 - Doctor Don't Know ...

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from