Okay, maybe I'm doing something wrong here... I have a page where I have used PHP to embed some ads, one every few paragraphs or so. These ads are all in a specific group. I have been using this as shown in the documentation:
<?php
print ad(17, 1);
?>
In Firefox, everything works great and I usually get several different ads. Sometimes, due to it being random it will repeat the same ad twice, but not often.
However, in Internet Explorer 8, in all three places where I embed the ad it will always show the same ad. Is there a way I can make it randomize properly?
If I embed multiple ads in the same place, instead of a single ad, it will display different ads. However, I would really like to space out the ads in the page, rather than leave them all in one clump. (It doesn't look too good to have two competing businesses appear right next to each other either.)
Comments
Comment #1
Geekish commentedMaybe I shouldn't have said 'embed' in the title of the issue. I forgot there is an ad_embed component. Just to clarify, I'm not using that at all.
Comment #2
jeremy commentedWhen you display multiple ads in one block (or by calling the ad function directly as you are doing) the ad function returns all your ads at once. When you display multiple ads in a series of calls to ad() this actually results in multiple HTTP requests and thus the ad module does not know which ads may have already been displayed on the page -- this can lead to the same advertisement being displayed multiple times.
As for what you're seeing with IE, evidently it is very aggressively caching the javascript probably trying to get better performance -- once the JavaScript runs once it sounds like it's caching the result and displaying it on subsequent runs of the same code. You may have better luck displaying ads with jQuery (though unfortunately I think that method is currently broken) or with the Raw display method.
Comment #3
Geekish commentedThanks for the explanation! It certainly looks like IE is aggressively caching the ad.
The jQuery method does seem to be broken at the moment, but the raw method works fine for me and randomizes the ads successfully. On the downside, I guess I have to turn off page caching to have it refresh the ads after the first page load. Hmmmm. The site I'm working on doesn't have a large number of visitors at one time, so maybe that wouldn't be too bad.
Seems the iFrame randomizes perfectly for me, which is ironic as I vowed never to use iFrames. Ever. Oh well... :-) I also see that someone has created a patch for the jQuery method. I might give that a try so I can see how that handles it. If I can get it to patch that is, as I'm not the best at that.
Thanks again for the help, now that I have a better idea of why my problem was happening, I can weigh out my options and decide which approach to take with this.
Edit: Just thought I'd add that I tried the patched module for jQuery from http://drupal.org/node/445264 and it seems to work fine so far (although I grabbed the file from the zip, as I wasn't able to patch it myself). It does randomize it properly as well. As long as I don't run into any issues with the patched version, I think jQuery is the best option for me.
Comment #4
jeremy commentedGlad you've gotten things into a workable state. Marking issue as fixed.