banner is not change in each page view!

Created on 30 April 2024, 7 months ago
Updated 19 September 2024, about 2 months ago

hi all
I have installed ad module version 4-0-0-beta4 on my drupal 10.
Also I have added 4 rectangle image banners via Add content AD section and I have placed a rectangle block inside content region.

every thing work fine and banner is shown in page view. but the problem is in every refresh the banner is same . indeed the first added banner is shown and module doesn't select random banner from all added banners.

can you help me what is my mistake in module configuration or maybe some bugs still exists in module codes !

💬 Support request
Status

Active

Version

10.0

Component

ad module

Created by

🇮🇷Iran Mehrdad201

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Mehrdad201
  • 🇮🇷Iran Mehrdad201

    I found that problem happened because pf getRandomAd function.

    getRandomAd function located at AdContentBucket.php only same the first item of each size and it seems random selector doesn't work.

    because every time after running the bellow code

          $result = $query
            ->range(0, 1)
            ->sort('id')
            ->execute();

    the first record of selected size is received and loaded to ad_content variable.

    I changed the code and now it works but I am not sure that what I have done is true or false.

    here is my changed code:

          $result = $query
            //->range(0, 1)
            ->sort('id')
            ->execute();
    
          if ($result) {
            shuffle($result)
            /** @var \Drupal\ad_content\Entity\AdContentInterface $ad_content */
            $ad_content = $storage->load(reset($result));
          }
  • 🇲🇽Mexico koffer

    I have the same problem!

  • 🇩🇪Germany Anybody Porta Westfalica
Production build 0.71.5 2024