1

I have a Drupal 7 site where I have a bunch of videos and I could use a little help with understanding the best way to show a small icon next to my video links after a visitor has viewed it. Is there a way to do this if they are anonymous visitors? My site does not have user accounts. Also, each of my videos are on a separate page and have a unique url.

I've looked briefly into the Flag Module, but I'm not sure if this work work as I don't want viewers to click on anything. I only to track their browsing.

Any help in the right direction would be much appreciated!

2 Answers 2

0

In my opinion using a cookie could be a nice way to accomplish that need. (Maybe even the only way). A quick search came up with the user_cookie_save function >> https://api.drupal.org/api/drupal/modules!user!user.module/function/user_cookie_save/7

Use it to save the cookie with the video URL or another identifier and read that cookie when loading the page and set the viewed flag.

0

Personally I find the simplest way (for anonymous users) is to use the :visited CSS selector.

.video a {
  display: inline-block;
  background-image: none;
  background-repeat: no-repeat;
  background-position: right;
  padding-right: 16px;
}
.video a:visited {
  background-image: url(icon.png);
}
2
  • I thought this was a brilliant idea till I came across this: stackoverflow.com/questions/14202856/…. It also doesn't work for me on all browsers. Thanks anway!
    – Dan
    Commented Jan 7, 2014 at 21:51
  • Yeah that's annoying. I've written a cookie version in the past too that just stores a serialized array of node ID's. That's what Rotem is suggesting. Commented Jan 13, 2014 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.