Options

Quick Co-branding Hack

Doug Munn - JLM PHOTODoug Munn - JLM PHOTO Registered Users Posts: 20 Big grins
Just tho't I'd share some code.

We want to offer add'l photo product services beyond what smugmug offers and we wanted to refer back our other site for processing.

NOW, I AM MAKING THE ASSUMPTION THAT THE "/1/" in the URL for a photo is a flag and I hope that it doesn't change.

This bit of code uses JavaScript (wish I could use something else) to grab the URL of the current page and pass it to my page at GearStores.

On my GearStores page, I can parse the URL and grab the image ID. That page isn't finished yet.

I put this code in the FOOTER section.

<script language="JavaScript" type="text/javascript">
var wl = window.location.href

if (wl.indexOf( "/1/")>0) {

document.write ("<form method=post action=http://www.gearstores.com/photos/orderpkg.php>")
document.write("<input type=hidden name='url' value='"+wl+"'>")
document.write("<center><input type='Submit' value='Order Quantity Prints, Package Prints and Screensavers Here'></center>")
document.write("</form>")
}

</script>

Comments, improvements welcome.


From drivng race cars to riding race horses, it's hard to keep the woman down.

Comments

  • Options
    onethumbonethumb Administrators Posts: 1,269 Major grins
    edited April 4, 2005
    Just tho't I'd share some code.

    We want to offer add'l photo product services beyond what smugmug offers and we wanted to refer back our other site for processing.

    NOW, I AM MAKING THE ASSUMPTION THAT THE "/1/" in the URL for a photo is a flag and I hope that it doesn't change.

    This bit of code uses JavaScript (wish I could use something else) to grab the URL of the current page and pass it to my page at GearStores.

    On my GearStores page, I can parse the URL and grab the image ID. That page isn't finished yet.

    This is a great question. Let me break down our URL scheme for you. The URL extends with optional parameters, so here's some examples of URLs that all point to the same image:



    http://jedi.smugmug.com/gallery/434393
    http://jedi.smugmug.com/gallery/434393/1
    http://jedi.smugmug.com/gallery/434393/1/17452049
    http://jedi.smugmug.com/gallery/434393/1/17452049/Medium

    So the breakdown goes like this:

    http://HOSTNAME/gallery/ALBUMID/PAGENUM/IMAGEID/SIZE

    ALBUMID is required, of course, and keys which album to go to. All of the others are optional and we can intelligently guess for them if they're absent.

    PAGENUM is a hint for which page we think the image is on. It's not a hard-and-fast rule, though, since people move images around, so in the event it's not the right page, we can properly find the right page. Technically, you can put whatever number you want here and it will just work.

    IMAGEID tells us what specific image to look for. Given a Style (Elegant, Elegant Small, etc) and an IMAGEID, we can get the PAGENUM ourselves and compare to see if it's accurate. If not, we discard it and use our internal number.

    SIZE tells us which size we'd like to view. It also causes smugmug to go into "single image view" rather than gallery Style view.

    Clear as mud?

    Don
  • Options
    NikolaiNikolai Registered Users Posts: 19,035 Major grins
    edited April 4, 2005
    uhm..
    NOW, I AM MAKING THE ASSUMPTION THAT THE "/1/" in the URL for a photo is a flag and I hope that it doesn't change.


    Actually, I've seen "/1/" been both present and not. I would not rely on it..

    I put this code in the FOOTER section.

    What codemwink.gif ?

    In case you didn't know, vBulletin does not handle soure code quotes well.
    THe only reliable way I found is to surround it with PHP quotes, and even in this case it disappears after preview or editing, so it's a one time deal..

    HTH

    "May the f/stop be with you!"
Sign In or Register to comment.