Active
Project:
Banner
Version:
4.7.x-1.x-dev
Component:
Banner Ads
Priority:
Critical
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Feb 2007 at 17:14 UTC
Updated:
27 May 2007 at 08:19 UTC
I have a group of banners at the top of my site at www.nyreia.org .
All of the banners are in the same banner group 2 .
For now I only have 3 banners. Is there any way that I can prevent duplicates of the same banner showing up within the same banner block section?
A lot of the time when the page reloads I see multiple images of the same banner which looks horrible. Does anyone have any way to prevent duplicate banners from showing within the same banner block from the same banner group?
Comments
Comment #1
rseiser commentedI had the same problem, and now I found the cause. The banner_db.php module (correctly) tries to prevent a banner from occurring multiple times by removing chosen banners from the ballot.
The problem is that if one gives chances larger than 1, the ballot gets filled with multiple instances of a banner (to increase its chances to get picked). Once a banner is picked, the module removes only one instance, but leaves the remaining instances in the ballot. Then they can get picked again, and so on.
The problem does not occur if all banners have chance equal to 1, since every banner is only one time in the ballot and will get removed when picked.
I have most banners with a chance of 10, except a rare one which I gave 1. If the module picks one of my high-probability banners, it removes one of the 10, but then there are still 9 left in the ballot. The correct way would be to remove the adjacent identical banners in both directions from the one picked. That way all 10 get removed from the ballot and cannot be picked anymore.
I am not sure how to do this the fastest (since there could be banners with a chance of 100), but going in a loop to remove one by one seems the only thing coming to my mind. If the array_splice command is slow, maybe one could just count the positions and at the end take out the section from position1 to position 2 (the first and last occurrence of the same banner instances). Maybe there is a faster way, e.g. replacing all the identical banners in the array with "" and then throw them out. Not sure if there are slick array functions for this. I will keep thinking. Contact me if you find a better solution.
Comment #2
rseiser commentedThis might not be the most elegant way, but I fixed it in a way that only adds a few lines and can be understood easily. Since it doesn't dig around within the array numbers, I also thought it is less error prone. Regarding speed, it would only slow down the algorithm if the random number generator keeps picking the same banner, e.g. if its chance was, say 100. But worst case, all 100 are removed from the ballot, and then the random number generator can move on. In a normal scenario, there are probably just a few banners to be displayed out of a large pool of banners. So it is a rare occurrence that the random number generator wouldn't find a new banner right away.
Comment #3
kenyob commentedIm a NEWB with patches. How do I patch this code?
Comment #4
rseiser commentedI also don't know how to submit or apply a patch properly. My above comment was meant for further review for the developer. If you want to apply it to your code, you might have to do this by hand. Comment out the lines marked with "-", and insert the lines with "+".