This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » General » Removing/Disabling Id data from...
expandshrink

Removing/Disabling Id data from URLs/paths contents

Removing/Disabling Id data from URLs/paths contents

Wednesday 01 September 2010 6:05:07 am - 6 replies

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

Modified on Thursday 02 September 2010 1:27:25 am by Russell Michell

Thursday 02 September 2010 8:45:28 am

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>

Thursday 02 September 2010 8:47:45 am

(...) 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 ?

Monday 13 September 2010 10: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 happy.gif Emoticon

Cheers
Russ

Thursday 16 September 2010 8:27:40 pm

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.

Friday 17 September 2010 1:19:42 pm

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

Friday 17 September 2010 4:24:28 pm

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.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from