It happens when I configured the link field's target to "Allow the user to choose". When the user creates a link for the first time, and checks the "Open URL in a New Window" checkbox, the first time I view the page, the link does open in a new window. But when I refresh the page, just pressing F5, the link doesn't open in a new window any more. If I edit the node (the "Open URL in a New Window" is still checked), and save it again, without changing anything, the link will open in a new window again, until I refresh the page, just like before.

I looked into the code in link.module, and I think I found what is causing the problem, although I don't know why. In the "_link_sanitize" function, the $item['attributes'] is an array, where $item['attributes']['target'] is set to "_blank". But when refreshing the page, $item['attributes'] is not an array any more, instead it has an string with the value "a:1:{s:6:"target";s:6:"_blank";}". I'm not sure what it means, it looks like the internal signature of the Array, but php does not recognize it as an Array object any more.

I attach here the link.module file with a temporal workaround I used to handle this. It's quite ugly, but I'm a beginner in module development, and I don't fully understand how it all works.

CommentFileSizeAuthor
link.module.txt25.57 KBjonigual

Comments

dropcube’s picture

Status: Active » Fixed

Could you please test the current dev version and re-open the issue continues. Thanks.

jonigual’s picture

Hi, I tested the current dev version and it all works fine. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -target, -_blank, -new window

Automatically closed -- issue fixed for 2 weeks with no activity.