Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Textpattern target blank?
I have a pdf in my files that i want to effectively target blank but im using the textpattern link builder, i dont want to use html.
how would i do this.
actually what i need is to make my pdf show up in a new tab or window instead of download.
answering either question is fine. thanks!!!!!
www.digitalskraps.com
Offline
Re: Textpattern target blank?
if it’s on file list then your file form could look:
<a target="_blank" href="<txp:site_url />files/<txp:file_download_name />"><txp:file_download_name /></a>
Or if it’s just link:
<a target="_blank" href="<txp:site_url />files/file.pdf">File.pdf</a>
Or it could be just:
<txp:file_download_link id="x" />
And if we are precise, then you should not use the target attribute, as it’s deprecated and only used with frames. Therefor you should use JS instead that is connected to rel="external"
.
Offline
Offline
#4 2008-06-17 08:32:03
- fastasleep
- Member
- Registered: 2008-06-17
- Posts: 10
Re: Textpattern target blank?
I had to figure out how to do this for a client, and here’s what I ended up changing:
- In textpattern/publish.php:
- Line 135:
change:
header('Content-Disposition: attachment; filename="' . basename($filename) . '"; size = "'.$filesize.'"');
to:
header('Content-Disposition: inline; filename="' . basename($filename) . '"; size = "'.$filesize.'"');
- In textpattern/includes/txp_tag.php:
- Line 3584
change:
$out .= tdb('<a href="'.$url.'"'.$description.'>'.$thing.'</a>');
to:
$out .= tdb('<a href="'.$url.'" target="_blank"'.$description.'>'.$thing.'</a>');
First one makes your pdf display in the browser window instead of forcing it to download. Second one tweaks the XHTML Tag Builder in the Files admin page adding target=”_blank” which opens it in a separate window. The first edit is retroactive, but you’ll have to manually go in and replace any existing file download links with the XHTML tag builder link to target a blank page.
Kinda hacky, but it seems to work, so… just in case this saves anyone the hours it took for me to dig through the source code and find this crap. :)
Last edited by fastasleep (2008-06-17 08:38:37)
Offline
#5 2008-06-17 13:12:47
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Textpattern target blank?
Thanks for sharing! :)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Pages: 1