Closed Thread Icon

Topic awaiting preservation: Set Cookie onclick, Based on Containing Div (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=27207" title="Pages that link to Topic awaiting preservation: Set Cookie onclick, Based on Containing Div (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Set Cookie onclick, Based on Containing Div <span class="small">(Page 1 of 1)</span>\

 
Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 12-23-2005 20:25

I've set up WordPress to start a blog of my travels and I've merged it with Gallery2 using WPG2. (You can see what I'm working on here, though the addition of images isn't done. See this thread for part of the reason why.)

I'm including relevant thumbnails at the bottom of the post, which lead to the album I've set up for that post. I hacked the breadcrumb so you don't end up backing out into irrelevant albums. (I'll lead from there into related content later.) Basically, each post has its own little album.

Unfortunately, WPG2 doesn't provide for any sort of navigation to find your way back where you came from. So I went and hacked in a couple of links (View All Media for Entry "X" and Back to Entry "X") for orientation and accessibility. The problem is I had to hack several different scripts and templates to make this work. So I'll have to be super careful when I upgrade things.

An additional, and bigger, problem is that only the thumbnail links work this way, since they're created dynamically with WPG2. I hacked WPG2 to include a query string that provides the necessary nav-link info once you're in Gallery. So I can't link my text within the post and still get the navigation, since only the WPG2-created links include the necessary info.

So here's my question: Is there a way to set a cookie using onclick and apply it to every link within a particular div? I'd have to set the cookie differently depending on which div the link is in (the div containing that particular post, the cookie recording which post you clicked from) and I can't add the onclick to the anchors themselves.

lan
Paranoid (IV) Inmate

From: Darwin, NT, Australia
Insane since: Dec 2003

posted posted 12-24-2005 00:11

Wes, on a vaguely - very - related note; did you ever solve your storage problem while travelling?
La Cie now sell an 8 gig, slightly bigger than credit card sized, USB memory card. I'll be able to give you a bit more info, if this fits your bill, after the jolly rotund feller visits tomorrow night. My gift ordering procedures should ensure that he has one loaded up with my address on it


Great set up on the travelogue, by the way. I have been playing around with a similiar guide type device and, so far it's a long rambling page - much like this post I guess - but much, much longer

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 12-24-2005 19:39

Wow, that discussion must've been a long time ago. I've had a 20GB FlashTrax for some time. It's proven to be enough space for regular use and I can keep it in my bag with me at all times.

I actually have a long and complicated backup procedure on the road. I have two flash cards for each camera that I rotate out -- when one fills, I switch them and stick the full one in the FlashTrax to copy it over. At the end of the day, I copy everything to the laptop, so I now have a backup copy. I also burn everything from that day to a DVD, stick it in a media envelope and mail it home -- that's my offsite backup in case something happens to my equipment. And when the FlashTrax gets full, I burn off a copy onto a DVD, which I keep in my suitcase, and clear the FT, but keep the laptop copy -- so I still have two local copies.

Wow, this thread went a direction I didn't expect. If you'd like to discuss it more, start a topic over in Photography and I'll be happy to continue.

In the meantime, anyone know if I can accomplish what I discussed above?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-27-2005 20:31

Ok sorry I got a bit confused when reading your first post but I think what you want to happen is this

1. someone clicks a link (or clicks something?)
2. Set a cookie for each link inside the div. I'm a little unclear on this point but if I understand correctly, for each link within the div you want to set a separate cookie?

Basic untested script would be something like this: (Note using the cookie scripts from quirksmode)

// 1. grab the div reference you can do this with some other handler

elm = document.getElementById('mydiv');

// 2. get all the links in an array
links = elm.getElementsByTagName("a");

// 3. Loop through and set cookies
for(i=0;i<links.length;i++) {
// Not sure what you want here but you probably want to use getAttribute to get the href and do something based on that
h = links[i].getAtttribute('href');
// to get the href
createCookie(something, something, something);
}

So there's the basic idea. If you want to do some extra switching based on the div you should be able to access the class name and id from the div as well.



.:[ Never resist a perfect moment ]:.

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 12-28-2005 06:07
quote:

bitdamaged said:

I'm a little unclear on this point but if I understand correctly, for each link within the div you want to set a separate cookie?



Almost -- not a separate cookie for each link, just a separate cookie for each div, set by any link within each div.

This may be moot, however, as I'm attempting to switch to a different system. But that's not going so well, either, so I'll probably be coming back to this.

If you have any Drupal experience, though, I could certainly use your help there.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-28-2005 06:18

lol
Funny you should mention it, I just started moving my site over to drupal



.:[ Never resist a perfect moment ]:.

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 12-28-2005 07:18

Maybe you're the man I'm looking for then.

« BackwardsOnwards »

Show Forum Drop Down Menu