Jump to content

Adding To A Movable Type Blog


Recommended Posts

I have a photoblog pixelfight.com What I want to do is add a small "purchase this photo" button on each of my individual archive pages. When you click on this button, it will lead to an order page, where people can view a smaller version of the image and order that particuar photo. I somehow have to pass a few variables from the individual page templet an order page. I just don't know how I can pass variables from one templet to the next.


An example on what I am trying to achieve can be located here (click on the "buy this photo" button). I'm trying to figure out how this person passed variables from the one page to an order page.. Anyone have any ideas? Maybe I have to involve PHP? I am stumped...



Link to comment
Share on other sites

On the page you linked to, the "Buy This Photo" icon is a link that runs a javascript when you click on it:

>onClick="goPurchase(); return false;"

In the View Source, the goPurchase() javascript function is located near the bottom of the page:

function goPurchase() {
   document.location.href = "/purchase.php?item=" + "0503/050321_1";
// -->

In javascript, the document.location.href method tells the browser to load the URL on the other side of the "=", which in this case evaluates to:


While browsing to the new URL, the URL contains one variable ("item") as a query parameter. The item number in the goPurchase() function will have a different item number on each web page, so the order page will know what picture is being purchased.


The javascript isn't strictly necessary to do this - you can construct image links that have a query parameter in them easily enough. I suspect that the icon has been included from another page, and the javascript coding allows the site to vary the link from page to page without losing the ability to include the image from another file.


There's a number of ways to pass variables to another page, but what you can do depends on where your order page expects to read those variables from.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...