DownloadItem by path?

nrutman

Joined: 2005-12-05
Posts: 6
Posted: Fri, 2005-12-09 01:56

Is it possible to use the DownloadItem by path? t seems to really want an itemId, which there's no easy way of figuring out afaik.

This works:
http://www.rutmans.org/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=8563
But what I want is for this to work:
http://www.rutmans.org/gallery/main.php?g2_view=core.DownloadItem&g2_path=beams/DSCF0049.JPG
Fundamentally, I suppose what I want is for this:
http://www.rutmans.org/gallery/beams/DSCF0049.JPG
to get me the DownloadItem view. But I think I can swing that with mod_rewrite if DownloadItem could take a path as a param.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-12-09 07:01

did you try using %path% in URL rewrite site admin? it might work, not sure..

 
nrutman

Joined: 2005-12-05
Posts: 6
Posted: Fri, 2005-12-09 16:36

Doesn't work, the DownloadItem script seems to demand an itemId or it returns an error.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-09 17:33

just use the default download item rule, which includes the id and the path

resulting in /d/id-serial/path URLs

 
nrutman

Joined: 2005-12-05
Posts: 6
Posted: Fri, 2005-12-09 17:46

The point is that I don't know the id#, all I know is the filename.
Say joe user sees a picture they want at
http://www.rutmans.org/gallery/beams/DSCF0049.JPG.html
All they know is the filename, not what internal id that Gallery has assigned to it.
They want to download this picture, I want them to be able to type
http://www.rutmans.org/gallery/beams/DSCF0049.JPG
and get the downloadItem for that path (I suppose the largest available version of the image).

Does that make sense? Is there a completely different way to do this that I'm not seeing?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-09 18:11

if you only have the filename, you can't call g2 directly.
you'll have to call GalleryCoreApi::fetchItemIdByPath($path);

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-12-10 05:36

there's a module in user contrib (click documentation in upper right, then find user contrib) to show you the urls for an item. you can also just use the path.html url, then right click on the image to copy its url. you could also compare the code for showitem rule and download rule in modules/rewrite/module.inc and see if it might be easy to allow %path% in the download rule.