URL Rewrite for downloads not taking effect

pnear

Joined: 2003-08-12
Posts: 18
Posted: Tue, 2005-09-13 17:09

URL Rewrite is working on my site, but the download links are not getting the proper URL applied to them on the album page.

Sample page:
http://www.thenears.com/gallery2/v/august_2005_rockwood/IMG_3817.JPG.html

Anchor tag construction from photo.tpl
<a href="{g->url arg1="view=core:DownloadItem" arg2="itemId=`$theme.item.id`"}">

URL generated for the downloaditem link on that page:
http://www.thenears.com/gallery2/main.php?g2_view=core%3ADownloadItem&g2_itemId=24458

Settings in the URLRewrite Config:
Download Item: d/%fileName%

Just updated to G2 1.0 via CVS this morning (this update didn't change anything, just noted to let you know what version I'm on).

Any thoughts?

Pete

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-09-13 19:31

nope, what g2 does is correct. it's just not well documented.

itemId and serial must be part of the url, if you leave them out, g2 will add them as normal url parameters.

recommendations: leave it as:
d/%itemId%-%serialNumber%/%fileName%

 
pnear

Joined: 2003-08-12
Posts: 18
Posted: Wed, 2005-09-14 13:30

Sorry, I should have noted that as well. It doesn't work with the default settings either, I changed them mostly to do some troubleshooting. I've reverted back to the setting you posted above, and am seeing the same behaviour.

Pete

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Wed, 2005-09-14 14:47

Try it with a different theme. This could be in how that theme creates the link. I've seen this before when playing around with "click on image for fullsize".

Actually changing themes won't help, I think this is how the themes work to generate the URL to download, they are hardcoded for that URL and don't "request" the URL from Gallery.
An example of a download link URL from the Matrix theme:

<a href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.item.id`"}">
  {g->text text="Download %s in original format" arg1=$theme.sourceImage.itemTypeName.1}
</a>

An example of the generated img URL from teh Matrix theme (without image frames)

{g->image item=$theme.item image=$image fallback=$smarty.capture.fallback}

Also, I didn't look at the WPG2 theme to confirm, but I'm pretty sure it does the same. Maybe one of the devs can point in the right direction of how to correctly get the URL for the download item so that it uses the URL Rewrite stuff if enabled.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-09-14 16:44

i don't believe it :)
please double and triple check.
go to site admin -> url rewrite
enter the above rule (d/%itemId%-%serialNumber%/%fileName%) for the download item requests.
hit save.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Wed, 2005-09-14 16:59

I think found the problem, or at least a problem. There appears to be a minor typo in photo.tpl of the WPG2 theme:

<a href="{g->url arg1="view=core:DownloadItem" arg2="itemId=`$theme.item.id`"}">

Instead of

<a href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.item.id`"}">

Note the period (.) instead of the colon (:) bewteen core and DownloadItem

I did a test on my site, http://photos.kevinnehls.com/v/G2Forums/netflix_voting0.png.html you'll see 2 download item links, one uses the short URL the other uses the long one. The short one is generated using core.DownloadItem, the long one is generated using core:DownloadItem

Looks like ozgreg needs to fix that if it's not fixed in the current version

 
pnear

Joined: 2003-08-12
Posts: 18
Posted: Wed, 2005-09-14 18:01

That was it! So, I grabbed the photo.tpl file from the siriux.net theme. Whoever owns that one might want to double check that it's been fixed there too.

I will repackage a point release of my wpg2connections theme that includes this fix.

Thanks!
Pete