Closed (fixed)
Project:
FileField
Version:
6.x-3.10
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Jun 2012 at 14:36 UTC
Updated:
10 Sep 2013 at 05:19 UTC
Jump to comment: Most recent
Comments
Comment #1
hillaryneaf commentedI am using a view to show the field, so maybe there are more options available there with theming?
Comment #2
jbova commentedYou may use the External Links module. You can configure the module's pattern matching field to match your files that should be opened in a new window. For example, to open all PDF documents in a new window, you can set the "Include patterns matching" field to the following:
.*\.pdfComment #3
OldAccount commentedIf you're using Views, you can use the "Rewrite results" option for that field. I forget how it's worded in D6, but it's one of the options in the field configuration. Check the box that says "Rewrite the output of this field" and the one that says "Output this field as a link" and you'll get a bunch of link settings, including target.
However, I appreciate the tip given in comment #2 because I'm working on a D7 site and wanted to set the link target for a file field but I'm not using Views and I preferred to avoid using Display Suite because it's a PITA to get it working with a Rate widget. The External Links module and pattern-matching took 5 seconds to set up, much easier. Thanks!
Comment #4
Anonymous (not verified) commentedI'm having the same issue in D7.
This may be ill-advised but if you like you can change the module/file/file.module file to add target="_blank" to all generic file links. Not wanting to install another module to open links in new windows I just changed the file directly. On my version I modified this, starting at line 734:
'type' => $file->filemime . '; length=' . $file->filesize,
),
to this
'type' => $file->filemime . '; length=' . $file->filesize,
'target' => '_blank',
),
Works for me so far.
Comment #5
quicksketchIt's ill-advised because you could easily accomplish your goal by copy/pasting the theme function you want to override into your theme's template.php. That way you can upgrade the module later and your theme contains the customizations. In this case, I think you would want to override theme_filefield_file(). See Overriding theme functions in the Drupal handbook.
Comment #6
jaesperanza commentedIn D6, there's a setting in your view > Fields (if you choose a fields-dependent Style) > Output this field as a link, then an option to open in new window.
Alternately, depending on your combined settings, you can set as Rewrite the output of this field > then enter custom code and fieldnames, example:
<a href=[your_file_pdf_upload] target=_blank>[your_field_title]</a>You can put in other fancy tags like title and other scripts if accepted. Again, this is for D6 in case anyone has a need for this.
Comment #7
jaesperanza commentedIn D6, there's a setting in your view > Fields (if you choose a fields-dependent Style) > Output this field as a link, then an option to open in new window.
Alternately, depending on your combined settings, you can set as Rewrite the output of this field > then enter custom code and fieldnames, example:
<a href=[your_file_pdf_upload] target=_blank>[your_field_title]</a>You can put in other fancy tags like title and other scripts if accepted. Again, this is for D6 in case anyone has a need for this.