Removing/Disabling Id data from URLs/paths contents

Author Message

Russell Michell

Tuesday 31 August 2010 9:05:07 pm

I recall reading somewhere how to remove translation IDs and version Ids from URLs and var dir paths but cannot remember if I dreamed it or it exists!

I have a link to a file embedded in a page: /content/download/<contentobject_id>/<arrtibute_id>/file/blah.xml, how can I disable these 'dynamic' elements in the URL, and as a default perhaps just overwrite a file when it gets updated?

I have no need for versioning of these kinds of files.

Thanks
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Jérôme Vieilledent

Wednesday 01 September 2010 11:45:28 pm

Hi Russ

I guess that you made some kind of attribute_view_gui to get this link. This is IMHO the best way to give a file for download. Another approach would be to display the physical link in your template :

<a href={$node.data_map.file.content.filepath|ezroot} target="_blank">{$node.data_map.file.original_filename|wash}</a>

Jérôme Vieilledent

Wednesday 01 September 2010 11:47:45 pm

"

(...) and as a default perhaps just overwrite a file when it gets updated?

I have no need for versioning of these kinds of files.

"

I don't get it... What do you need exactly ? Are you talking about import ?

Russell Michell

Monday 13 September 2010 1:34:41 pm

"
"

(...) and as a default perhaps just overwrite a file when it gets updated?

I have no need for versioning of these kinds of files.

"

I don't get it... What do you need exactly ? Are you talking about import ?

"

Hi there,

No I'm not talking about import. I have overridden embed.tpl so I can directly download files instead of having to click twice to download it. However the URI of the link appears like this:

/content/download/12345/78964/file/blah.pdf

I wanted to remove the 12345/78964 part. I managed it using ReWrites but it got too complex to manage!

It's not too important now I can live with it. However, I don't think downloading a file should really make any underlying systems viewable to the user. Would it not be desirabl and more flexible in tems of template overrides if it were transparent? The URI would look like /content/download/file/blah.pdf but eZ simply fetched the latest version of blah.pdf - better, the URL would take the form of the file-structure in Media/Files so you could have multiple files named "blah.pdf".

Thanks anyway, I have got what I needed for now :-)

Cheers
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Marko Žmak

Thursday 16 September 2010 11:27:40 am

Russell, the thing that you are trying to achieve seems pretty much theoretically impossible...

Let's say for example that you have a content class "Double file" which has two attributes of type "File". And let's say that you create an object of this class and upload a file in each of this two attributes both files named blah.pdf.

So now what would be the URL for downloading each of this files? How would you know the difference between them without putting the attribute id (or identifier) in the URL?

As for your remark:

"

However, I don't think downloading a file should really make any underlying systems viewable to the user.

"

look at all those download sites on the net, they all have some kind of ID in the URL that reveals some part of the underlying system. So it's perfectly reasonable.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Gaetano Giunta

Friday 17 September 2010 4:19:42 am

If you only have a single attribute with the binary file in your content class, you might:

1) simple solution: use an http redirect

2) create a new fetch function and serve the binary content via template (hackish!)

3) create an alternative module to content/download

for 1: override full.tpl for your class, in it just set a redirect_location in the persistent_variable that points to the correct :content/download/xxx link, and in the pagelayout check if redirect_location is set, and if it is, do an http redirect to it (needs a new tpl operator for it)

for 2: override full.tpl for your class, in it set a file_location and mime_type in the persistent_variable; the again add code in the pagelayout that when those variables are found juset does a readfile() of the binary content and sends appropriate mime headers

for 3: I'll leave it up to you to code the new module+view that looks up node id by path and then gets the binary file and pipes it to the user. Urls might look like /my/download/path/to/the/node - here again you should add rewrite rules / redirects to get to a "clean" solution

Principal Consultant International Business
Member of the Community Project Board

Marko Žmak

Friday 17 September 2010 7:24:28 am

The solution that I use for classes that have only one file attribute is to do a HTTP redirect to the /content/download/12345/78964/file/blah.pdf URL in the full view of the file class.

You can do the redirection using RedirectOperators contribution.

Of course, in security context, this doesn't hide completely the IDs from the user but it does hide the "ugly" url from the user.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 05:00:01
Script start
Timing: Jan 18 2025 05:00:01
Module start 'layout'
Timing: Jan 18 2025 05:00:01
Module start 'content'
Timing: Jan 18 2025 05:00:03
Module end 'content'
Timing: Jan 18 2025 05:00:03
Script end

Main resources:

Total runtime2.2833 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 589.1719152.6406
Module start 'layout' 0.00760.0045 741.812539.4922
Module start 'content' 0.01222.2699 781.3047701.0000
Module end 'content' 2.28200.0013 1,482.304720.1250
Script end 2.2833  1,502.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.1481160.0002
Check MTime0.00140.0595160.0001
Mysql Total
Database connection0.00100.044510.0010
Mysqli_queries2.196496.1928740.0297
Looping result0.00130.0548720.0000
Template Total2.247898.421.1239
Template load0.00190.081220.0009
Template processing2.245998.362721.1230
Template load and register function0.00020.009010.0002
states
state_id_array0.00080.036710.0008
state_identifier_array0.00280.123620.0014
Override
Cache load0.00170.0758590.0000
Sytem overhead
Fetch class attribute can translate value0.00080.036940.0002
Fetch class attribute name0.00150.0643110.0001
XML
Image XML parsing0.00480.210340.0012
class_abstraction
Instantiating content class attribute0.00000.0010140.0000
General
dbfile0.00440.1910370.0001
String conversion0.00000.000440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 38
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs