We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8190
    • 21 Posts
    Hello,

    I created a module wich makes it possible to place banners on a website.
    Basicly it works like this:
    in the manager the admin can upload an image (jpg, gif) and fill in a form with information like the company, the url where the banner should redirect to and so on.
    You can place a banner like this: [[Banner? &width=200 &height=113]]
    Then all the banners with the given width and height are loaded and randomly one is placed.
    This works fine. But I would like to be able to see how often a banner is shown on an page and how often is clicked.
    The clicked part works fine but the view-part is where it goes wrong.

    The code:
    $sql2 = "UPDATE banners set view = ’".($row[’view’]+1)."’, viewtotal = ’".($row[’viewtotal’]+1)."’, geplaatst = 1 WHERE id = ".$row[’id’];

    For some reason this code is executed 4 times. The banner is only displayed one time, but the update number of views part executes 4 times.
    How is this possible?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would imagine that on your test system you’ve got 4 qualifying banners, and that query gets executed during the random selection process, or in some other way it gets executed once for each possible banner.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7231
        • 4,205 Posts
        [[Banner? &width=200 &height=113]]
        Maybe change the call to an uncached call (so that it gets executed with fresh data every time) by changing the call to use [! !]
        [!Banner? &width=200 &height=113!]
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 10449
          • 956 Posts
          Do you use the preview tab after editing a document?