Just wondering if anyone has a solution for forcing links to pdf files (inserted into a node body) to open in a new window?

You can achieve this with file field—http://drupal.org/node/301234#comment-4764468

thx

Comments

davesommerhalder’s picture

Any ideas?

frankdesign’s picture

Issue summary: View changes

Anyone come up with a solution for this?

F

frankdesign’s picture

OK, I found a solution for anyone that stumbles on this page looking for an answer. This solution will open all inserted files in a new window.

In the Insert module folder, there is a folder called templates. Inside there is a file called insert-link.tpl.php. Copy that file to your templates folder in your theme folder. Then edit the copied file to add target="_blank" directly after the text <a href="<?php print $url ?>" so you end up with <a href="<?php print $url ?>" target="_blank" <?php print $class ? ' class="' . $class . '"' : '' ?> title="__description__">__description_or_filename__</a>

Now when you insert a PDF into the body text, the linked file will open in a new window.

Would be nice to have it as an option when inserting a file, but this workaround works perfectly for me on the site I am working on.

F

Snater’s picture

Status: Active » Closed (works as designed)

I acknowledge this being an old issue and I deal with the Drupal 7 version occasionally only. Yet, I am not sure there should be an option for this as one should probably either open all files in a new window or all files in the same window. As demonstrated, altering the behaviour for all files can be done by altering the template. However, you should not edit the Insert module's native template, but rather overwrite the template with your own. To do that, you need to create a plain subtheme of your admin theme, install it and place your version of the insert template in the subtheme's templates folder.