Okay...first off I am not a php developer so this is a "hey do you think this will work?" thread moreso than a tutorial.

Problem:

I want to display 4 ads in block location 3. I also have a banner ad at the top and a skyscraper on the left. I do NOT want 4 ads in those locations.

Last week I installed OpenX and created some ad blocks in the admin panel and it works in such a manner that I now have the number of ads per block I want. The bad part is now I'm using a 3rd party solution and creating more work for myself.

Possible solution?:

I opened /module/ad/include/service/ad.class.php

Find:

if ($iTotal < count($aAds) && Phpfox::getParam('ad.how_many_ads_per_location') > 0)


I changed that to:

if ($iBlockId = '3' AND $iTotal < count($aAds) && Phpfox::getParam('ad.how_many_ads_per_location') > 0)


That seems to work. At least it is showing correctly on my site. No syntax errors according to Dreamweaver and not showing any errors in debug on the site. But I'm still unsure of my code. Perhaps someone familiar with the code can take a quick peek and see if this looks legit or if it just seems to be a fluke that it's working for me?
Last update on February 20, 2013 by SlideRiceFC.
Be the first person to like this.
Donna(data66)
I can leave this here where it is fine but Purefan seems to look in the Coding area. did you want me to put it there in case he looks tomorrow or wait to see if someone else answers?
Be the first person to like this.
Thanks. Yes, if you think it'll catch the eyes of Purefan, Fern and other coding folks that might be better.
Be the first person to like this.
There is not enough context in your post for somebody who does not use either blocks or ads (me) to answer your question in terms of the big picture: is it logically correct within the system?

That is, I do not know what values and meanings for $iTotal and $iBlockId, how they are used or what the implications might be. That's a different level of analysis.

But syntactically your if statement looks fine.

if (A AND B && C)

The double ampersand is syntactically equivalent to the word AND.

You are testing three conditions (you have a logical conjunction).

php will evaluate your conditions left to right, stopping when it meets a falsey value.

EG If iTotal is less than count(ads) the remaining conditions will not be checked.

The code will fail if $iBlockId=3 and $aAds is not an array. If there is not a check for that prior to your snippet getting executed, insert another condition after the block check; test for isset($aAds)

You get a gold star.
Be the first person to like this.
I was wondering if the double ampersand was the same as AND since I've seen and used both when playing around. Think I'll at least change that much for consistency. Thanks for taking the time to explain some of this to me.

I will check on those arrays although I'm fairly certain that's where I pulled my snippets from.

So far so good. I've never been hesitant to play with php in templates to get things to work like I wanted but this is the first time I tried to change how something worked. I guess I really need to get off my butt and crack open some books and read some tutorials so I can finally start getting my site to do what I want it to do.
Be the first person to like this.
ElekTrO
Quote:
Originally posted by: SlideRiceFC

Okay...first off I am not a php developer so this is a "hey do you think this will work?" thread moreso than a tutorial.

Problem:

I want to display 4 ads in block location 3. I also have a banner ad at the top and a skyscraper on the left. I do NOT want 4 ads in those locations.

Last week I installed OpenX and created some ad blocks in the admin panel and it works in such a manner that I now have the number of ads per block I want. The bad part is now I'm using a 3rd party solution and creating more work for myself.

Possible solution?:

I opened /module/ad/include/service/ad.class.php

Find:

if ($iTotal < count($aAds) && Phpfox::getParam('ad.how_many_ads_per_location') > 0)


I changed that to:

if ($iBlockId = '3' AND $iTotal < count($aAds) && Phpfox::getParam('ad.how_many_ads_per_location') > 0)


That seems to work. At least it is showing correctly on my site. No syntax errors according to Dreamweaver and not showing any errors in debug on the site. But I'm still unsure of my code. Perhaps someone familiar with the code can take a quick peek and see if this looks legit or if it just seems to be a fluke that it's working for me?


Are you using 3.7 beta2? I understand its a beta and there is no support for it, but maybe anyone or someone can help me.

I have enable multi-ads location, created an ads and when done I click on "create" nothing happens. Can someone help me with this kind of issue?
Last update on August 22, 2013 by ElekTrO.
Be the first person to like this.
Donna(data66)
Did you follow the tutorial in the knowledgebase for this feature?
Be the first person to like this.
ElekTrO
Quote:
Originally posted by: data66

Did you follow the tutorial in the knowledgebase for this feature?


the problem is the multi-ads is not capable of https, if I use http it will work but ads wont display.So how would I allow the https url on the ads when creating an ads?
Be the first person to like this.
Hi does anybody know if i have ads set to 7 per block in settings/ad
but in block 4 I only want to show 1 ad
how would i change this code?
thanks in advance
Be the first person to like this.
Younet have an ads module to be released soon, don't know any of the specifics yet, that might be of interest.
Be the first person to like this.
ok thanks
Be the first person to like this.