Link does not open in new tab

  • Posts: 18
  • Thank you received: 0
11 years 1 week ago #162280

I have an editor which is launched within hikashop.
When a photo is created through the editor, I submit it to the cart via the "update cart" url.
I have a custom field which will hold the value of the link to that created photo (see attachment "uw foto: url").
I'm not wondering how I can make sure that the link is opened in a new tab. Whenever I add target="blank" for that url, it gets removed...

Attachments:
Last edit: 11 years 1 week ago by MaartenVdp.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
11 years 1 week ago #162317

The correct attribute is target="_blank" (with the underscore). For example

<a href="http://www.your-link.com" target="_blank">My Link</a>

Try that and it should work.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 84052
  • Thank you received: 13626
  • MODERATOR
11 years 1 week ago #162281

Hi,

If you use a custom field of the type "file" and provide to it the name of the file that you saved in the upload secure folder of HikaShop, the custom field would automatically display a link to it with a target="_blank" on it.
So in such respect, there would actually be nothing to change.
So I'm not sure how you configured your custom field nor how you add the link to the file in the custom field. Did you use a custom field "text" type and then added the a HTML tag directly in its content ? In that case, it's normal that the attribute is removed. That is done by the filtering system in order to avoid XSS injection attacks via custom fields. It's possible to deactivate that filtering for your custom field by turning off the "input filtering" option of the custom field, but I don't recommend that for custom fields where the value is added in the frontend as it would make your website vulnerable to such attacks. A safer solution would be to edit the file "cart" of the view checkout" via the menu Display>Views and change the code:
$this->fieldsClass->show($field,$row->$namekey)

to:
str_replace('<a ','<a target="_blank" ',$this->fieldsClass->show($field,$row->$namekey))

That way, the target would be added server-side.

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum