Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
davesommerhalder CreditAttribution: davesommerhalder commentedAny ideas?
Comment #2
frankdesign CreditAttribution: frankdesign commentedAnyone come up with a solution for this?
F
Comment #3
frankdesign CreditAttribution: frankdesign commentedOK, 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
Comment #4
Snater CreditAttribution: Snater commentedI 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.