Advertisement Management

Adding multiple ads on the same position doesn't cycle them - Advertisement Management

Adding multiple ads on the same position doesn't cycle them

by OciXCrom™ » Thu Dec 07, 2017 7:27 pm

When I add multiple ads on the same position (in my case "below header"), it only shows the first one in the list. No matter how many times I refresh the page, the ad doesn't change.
OciXCrom™
Registered User
Posts: 17
Joined: Thu Dec 07, 2017 7:25 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by VSE » Fri Dec 08, 2017 7:40 am

What kind of database?

What are the priority settings?
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.
User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4596
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by OciXCrom™ » Fri Dec 08, 2017 12:39 pm

I'm using PHPBB 3.2.1. The priority was default (5) for all of them. I tried changing it - set every priority to 1 - no effect. Even setting a higher priority on 1 ad while others have a lower one didn't show that ad.
OciXCrom™
Registered User
Posts: 17
Joined: Thu Dec 07, 2017 7:25 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by VSE » Fri Dec 08, 2017 2:32 pm

What kind of database?
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.
User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4596
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by OciXCrom™ » Fri Dec 08, 2017 5:51 pm

Sorry, I'm not very familiar with these things. I believe MySQL is the answer to your question.
OciXCrom™
Registered User
Posts: 17
Joined: Thu Dec 07, 2017 7:25 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by scudderfish » Sun Dec 17, 2017 9:12 pm

We are seeing the same behaviour. Multiple ads set up for the same location, only the first one that is enabled is displayed regardless of what priority values are chosen. phpbb3.2.1 on MySQL
scudderfish
Registered User
Posts: 5
Joined: Sun Dec 17, 2017 9:09 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by Lucan » Mon Dec 18, 2017 8:55 am

Same here. Running MySQL 5.7
Prirority for all Ads is 5
Lucan
Registered User
Posts: 39
Joined: Fri Jun 13, 2008 10:24 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by scudderfish » Mon Dec 18, 2017 6:11 pm

OK, I dug the SQL out of the extension and had a play in the MySQL console. If I run this :-

Code: Select all


SELECT location_id, ad_id, ad_code
            FROM (            
SELECT al.location_id, a.ad_id, a.ad_code
                FROM phpbb3_ad_locations al
                LEFT JOIN phpbb3_ads  a
                    ON (al.ad_id = a.ad_id)
                WHERE a.ad_enabled = 1
ORDER BY (RAND() * a.ad_priority) DESC ) z;
I get a random order of ads (all of them have the same location). However, if I add the order by clause :-

Code: Select all

SELECT location_id, ad_id, ad_code
            FROM (            
SELECT al.location_id, a.ad_id, a.ad_code
                FROM phpbb3_ad_locations al
                LEFT JOIN phpbb3_ads  a
                    ON (al.ad_id = a.ad_id)
                WHERE a.ad_enabled = 1
ORDER BY (RAND() * a.ad_priority) DESC ) z
ORDER BY z.location_id;
Then MySQL returns them in location_id,ad_id order and the random selection is gone.
scudderfish
Registered User
Posts: 5
Joined: Sun Dec 17, 2017 9:09 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by scudderfish » Mon Dec 18, 2017 9:51 pm

OK, modifying line 72 of ad/manager.php to be

Code: Select all

		$sql = 'SELECT location_id, ad_id, ad_code
			FROM (
				SELECT al.location_id, a.ad_id, a.ad_code
				FROM ' . $this->ad_locations_table . ' al
				LEFT JOIN ' . $this->ads_table . ' a
					ON (al.ad_id = a.ad_id)
				WHERE a.ad_enabled = 1
					AND (a.ad_end_date = 0
						OR a.ad_end_date > ' . time() . ")
					$sql_where_views
					$sql_where_clicks
					AND " . $this->db->sql_in_set('al.location_id', $ad_locations) . '
				ORDER BY location_id ASC, (' . $this->sql_random() . ' * a.ad_priority) DESC
			) z';
appears to fix it. This is only testing on a handful of ads on MySQL, so I don't know if this breaks other databases.
scudderfish
Registered User
Posts: 5
Joined: Sun Dec 17, 2017 9:09 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by OciXCrom™ » Sat Dec 30, 2017 1:22 pm

Is the fix going to be applied in the official release sometime soon?
OciXCrom™
Registered User
Posts: 17
Joined: Thu Dec 07, 2017 7:25 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by OciXCrom™ » Tue Jan 02, 2018 2:53 pm

scudderfish wrote:OK, modifying line 72 of ad/manager.php to be

Code: Select all

		$sql = 'SELECT location_id, ad_id, ad_code
			FROM (
				SELECT al.location_id, a.ad_id, a.ad_code
				FROM ' . $this->ad_locations_table . ' al
				LEFT JOIN ' . $this->ads_table . ' a
					ON (al.ad_id = a.ad_id)
				WHERE a.ad_enabled = 1
					AND (a.ad_end_date = 0
						OR a.ad_end_date > ' . time() . ")
					$sql_where_views
					$sql_where_clicks
					AND " . $this->db->sql_in_set('al.location_id', $ad_locations) . '
				ORDER BY location_id ASC, (' . $this->sql_random() . ' * a.ad_priority) DESC
			) z';
appears to fix it. This is only testing on a handful of ads on MySQL, so I don't know if this breaks other databases.
This didn't work for me. There's still only one ad showing all the time.
OciXCrom™
Registered User
Posts: 17
Joined: Thu Dec 07, 2017 7:25 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by AlexPell » Fri Jan 12, 2018 12:30 pm

Fixed. (Working on phpBB 3.2.1).

Edit file:
/ext/phpbb/ads/ad/manager.php : starting from ~ line 72

Code: Select all

		$sql = 'SELECT location_id, ad_id, ad_code
			FROM (
				SELECT al.location_id, a.ad_id, a.ad_code, (' . $this->sql_random() . ' * a.ad_priority) rand_priority 
				FROM ' . $this->ad_locations_table . ' al
				LEFT JOIN ' . $this->ads_table . ' a
					ON (al.ad_id = a.ad_id)
				WHERE a.ad_enabled = 1
					AND (a.ad_end_date = 0
						OR a.ad_end_date > ' . time() . ")
					$sql_where_views
					$sql_where_clicks
					AND " . $this->db->sql_in_set('al.location_id', $ad_locations) . '
			) z
			ORDER BY z.location_id, z.rand_priority DESC';
AlexPell
Registered User
Posts: 3
Joined: Tue Jan 09, 2018 11:13 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by scudderfish » Sat Jan 13, 2018 11:20 am

Now we just need it included in 1.0.5 :)
scudderfish
Registered User
Posts: 5
Joined: Sun Dec 17, 2017 9:09 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by OciXCrom™ » Sat Jan 13, 2018 12:38 pm

I'm still using the 3.1 version because it has more options + it works like it should. Please fix this and add the ad group extra.
OciXCrom™
Registered User
Posts: 17
Joined: Thu Dec 07, 2017 7:25 pm
Contact:

Re: Adding multiple ads on the same position doesn't cycle t

by AlexPell » Sat Jan 13, 2018 9:57 pm

OciXCrom™ wrote:I'm still using the 3.1 version because it has more options + it works like it should. Please fix this and add the ad group extra.
Doesn't my fix work for you?
AlexPell
Registered User
Posts: 3
Joined: Tue Jan 09, 2018 11:13 pm
Contact: