searching the forums, I see a lot of requests for this. I have found snippets to have attached files (either attached thru upload module or cck file field) open in a new window.
Views, awesome as it is, breaks all of these snippets. I don't want my pdfs opening in the same window. Is there a workaround, or any info? Can this become a feature?
thanks,
cg
Comments
Comment #1
dawehnerYou can use "rewrite output" or theming. There you could use target = _blank, which is bad, because its outdated or you can use js.
Comment #2
cgjohnson commentedthanks dereine - I've had trouble using rewrite output, because I have two attachments in some nodes, and when I rewrite them using replacement patterns, it shows up even when that field is empty (ie, it's fine on the nodes that have two attachments, but if there's only one, both fields still show up, one with just the icon).
Any idea how to rewrite output in a way that doesn't show the field if there is nothing in it? It would be great to say [file_pdf_fid2] rel="new" etc. but have it only appear if the field [file_pdf_fid2] isn't null.
thanks.
Comment #3
esmerel commentedThis issue is a year old, it's likely either resolved or no longer relevant.
Comment #4
thomaslucas commentedSame problem here, anyone find an elegant way to open in new window the pdf attachments on cck filefield?
Thanks
Comment #5
stevenator commentedthe simplest way I see to do this would be to copy the theme function from filefield_formatter.inc to your theme and write the code you want; so simply a copy/paste. I don't really see a way to do this without getting your fingers dirty in a little code but maybe someone will want to write a feature for the "generic url" formatter that gives the option to open in a new link. I am on 6.22 using cck 6.x-2.9 and filefield 6.x-3.9...All I did was alter the $options variable to include the attribute for the target. Here is the codes:
Comment #6
zjoriz commentedSounds good, stevenator!
Where should I put the script in order to make it the preferred script instead of filefield_formatter.inc? Maybe just altering filefield_formatter.inc and tagging it read-only would do the trick as well?
I suspect I would need to be extra careful when updating FileField in any case...
EDIT: I found this idea of writing a new filefield output using Views Custom Field and decided to go for that approach. Probably not the cleanest option, but it looks like it should and even works like it should.