Forums / Setup & design / Open PDF directly in a new browser window from link in OE

Open PDF directly in a new browser window from link in OE

Author Message

Siw Helen Thorslund

Wednesday 26 April 2006 1:19:24 pm

Maybe this is a stupid question, but I just can't remember how to open a PDF directly in a new browser window from link in Online Editor.

I'm using this code:

Read the <link href='ezobject://373' target='_blank'>PDF</link> here.

Any idea how to get this to work?

I do not want to open the full view of PDF, but the direct link to the file...

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Łukasz Serwatka

Wednesday 26 April 2006 11:22:32 pm

Hi Siw,

You will need to use content/pdf/<node_id> and generate PDF file on the fly.

Read the <link href='content/pdf/<node_id>' target='_blank'>PDF</link> here.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Siw Helen Thorslund

Thursday 27 April 2006 1:50:31 am

I do not want that article as an pdf, but I want the link to a certain pdf uploaded in the media gallery. The link to where it is located in the var directory. How to do this as easy for the user as possible?

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Vicente Olivan

Thursday 27 April 2006 2:29:31 am

It would have to work.

Test also:

 

Read the <link href='eznode://373' target='_blank'>PDF</link> here. 
 

Regadrs

Łukasz Serwatka

Thursday 27 April 2006 2:30:40 am

User can use /content/download/2241/22891 instead of /content/download/2241/22891/version/1/file/file.pdf. So basically have to remember object_id and attribute_id. With ezobject and eznode you can link to object/node not to attribute of object. There is no easy way to do this. Furthermore uploaded files are renamed (ezbinaryfile) e.g var/plain/storage/original/application/0dd976dd601a968d7dda515340dc5939.pdf all information are in database and eZ publish download module hadle it.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Siw Helen Thorslund

Thursday 27 April 2006 12:30:38 pm

That works, but is not a very good solution for the users.
But I guess I have to do it this way for now...

What about having it to open directly in the browser window?
Not for download like the code in the example; /content/download/2241/22891.

I tried; /content/view/full/2241/22891, but no luck.

(Still the problem is within Online Editor)

Any suggestions?

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Siw Helen Thorslund

Wednesday 31 May 2006 5:34:09 pm

This is still not a very good solution for the users.

I have tried something like:

{section show=$href|contains("pdf")}

	PDF <a href={$href|ezroot()}{section show=$id} id="{$id}"{/section}{section show=$title} title="{$title}"{/section}{section show=$target} target="{$target}"{/section}{section show=ne($classification|trim,'')} class="{$classification|wash}"{/section}>{$content}</a>

{section-else}

	OTHER <a href={$href|ezurl}{section show=$id} id="{$id}"{/section}{section show=$title} title="{$title}"{/section}{section show=$target} target="{$target}"{/section}{section show=ne($classification|trim,'')} class="{$classification|wash}"{/section}>{$content}</a>

{/section}

I need for the PDF to direct to it's filepath to directly open it, and not end up with linking to the full view of the object.

In ezxhtmlxmloutput.php handler, I can see only 'href', 'target', 'classification', 'title', 'content', and 'id' ... which are of no use.

Anyone with a good idea how to solve this?

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Heiner Wurbs

Tuesday 29 August 2006 3:13:41 am

This is a solution, not perfect, but it works

{section show=$href|contains("pdfdownloads")} 
	{def $my_node=fetch( 'content', 'node', hash( 'node_path', $href ) )}
	{*again a condition, to be sure, it is a pdf file*}
	
	{section show=$my_node.object.data_map.file.content.original_filename|ends_with( '.pdf' )}
		<a href=/content/download/{$my_node.object.data_map.file.contentobject_id}/{$my_node.object.data_map.file.id}/file/{$my_node.object.data_map.file.content.original_filename }>{$content|wash( xhtml )}</a>
	{section-else}
		<a href={$href|ezurl}{section show=$id} id="{$id}"{/section}{section show=$title} title="{$title}"{/section}{section show=$target} target="{$target}"{/section}{section show=ne($classification|trim,'')} class="{$classification|wash}"{/section}>{$content}</a>
	{/section}
{section-else}
	<a href={$href|ezurl}{section show=$id} id="{$id}"{/section}{section show=$title} title="{$title}"{/section}{section show=$target} target="{$target}"{/section}{section show=ne($classification|trim,'')} class="{$classification|wash}"{/section}>{$content}</a>
{/section}

it fetches the node by the $href, which is my case sth like media/pdfdownloads/myfiles/mypdf.pdf

To be sure, that it is a pdf, I added an ends_with condition.

Greetings
Heiner

PS: this is definitiv more comfortable for users than an object relation. The user can simply add a link on any text or object and search for a node or object

eZ debug

Timing: Jan 21 2025 20:23:21
Script start
Timing: Jan 21 2025 20:23:21
Module start 'content'
Timing: Jan 21 2025 20:23:21
Module end 'content'
Timing: Jan 21 2025 20:23:22
Script end

Main resources:

Total runtime0.4613 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0104 587.9688180.7969
Module start 'content' 0.01040.0169 768.7656106.1016
Module end 'content' 0.02730.4340 874.8672534.2969
Script end 0.4612  1,409.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.9251200.0002
Check MTime0.00160.3566200.0001
Mysql Total
Database connection0.00170.370710.0017
Mysqli_queries0.382482.89851410.0027
Looping result0.00150.31611390.0000
Template Total0.433493.910.4334
Template load0.00180.385410.0018
Template processing0.431693.560610.4316
Override
Cache load0.00090.185110.0009
Sytem overhead
Fetch class attribute can translate value0.00100.220910.0010
XML
Image XML parsing0.00030.062010.0003
General
dbfile0.01843.9817200.0009
String conversion0.00000.001830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs