Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Using MetaMod Pro with iJoomla AdAgency for Localized Pages

Using MetaMod Pro with iJoomla AdAgency for Localized Pages

Hi Stephen (et al)...

Here's a brief scenario that I need some help with.

An international site also provides "local landing pages" that are city-specific.

I have ad zones setup that display solely on those pages, however I need to display Run of Site (default) ads if no targeted ads are available.

From the MetaMod perspective, I need a recipe that will display a "backup" module if the primary (targeted ad module) is empty.

Any idea how?  :-)

Example:  if module #100 is empty, display module #200 - or, to go a bit further, let's even say multiple options:  if module #100 or #101 are empty, display module #200

~Matt

Edited By: mlipscomb
22-Mar-11 21:30:10

~Matt Lipscomb
Joomla! Leadership Team | Web Developer & Designer
http://www.usafreelancers.org/

mlipscomb
Web Developer
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

Hi Matt,

the issue here is how MetaMod is going to determine whether or not the other modules are empty.

Does each (non-MetaMod) module make its own decision about whether to display something or not? If so, then you need to somehow give MetaMod access to the same decision-making process.

If you're using MetaMod to make the decisions, then of course it's easier to make a chain of rules:

if (something) return 101;
else if (something else) return 102;
else return 103;

I guess it's not going to be as easy as that. I think you're going to need to understand more about how AdAgency decides when to display certain ads.

Does AdAgency do this on the your own server, or does it query an ad server somewhere else for this information?

Does AdAgency have an API that you can query?

How does AdAgency normally handle the situation where an ad is not available for that particular location/criterion? Does it simply display an empty module? That must get difficult for your template to handle...

All in all this is quite a tricky situation. The more info you can find out about AdAgency, the better. Is it free/opensource?

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

It is a bit tricky.  I contacted iJoomla to determine what output is created if there is no ad available.

Assuming the module is empty (produces no output with the module title off) or assuming if there is no ad available it simply produces a php variable, then the question would be can MetaMod pick up on the variable or the empty output.

iJoomla AdAgency is GPL and is in the JED: http://extensions.joomla.org/extensions … ment/14294

The ad server is local, but even if it was remote, it still has a module you install, so still the same basic concept.

To my knowledge, it does not have an API.

It *does* simply place an empty module there.  However, that can be controlled with Advanced Module Manager to turn it off if it's empty.  So if I use that, then the question is how do I detect if it's been 'hidden' or empty by Advanced Module Manager?

Fun times, fun times :-)

~Matt Lipscomb
Joomla! Leadership Team | Web Developer & Designer
http://www.usafreelancers.org/

mlipscomb
Web Developer
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

I've been thinking about this - I suppose I could run an SQL statement to get the results of the ad zone and campaign, for example something like:

Code:


SELECT from #__ad_agency_campaign WHERE id={CAMPAIGN ASSIGNED TO THAT ZONE} and approved=Y

SELECT from #__ad_agency_banners where zone={THE MODULE/ZONE ID} and approved=Y and campaign={CAMPAIGN ASSIGNED TO THAT ZONE}

(Zones and Campaigns are approved separately, it would need to test for any campaigns assigned to that zone and make sure they are approved and then any banners assigned to that zone and approved)

Then if that result is empty/null, return the default module.

So, setting a php variable that runs the sql: 

$adZone1=(the SQL Statement)
if $adZone1=() return "moduleID as the default";

Does that sound possible/practical?

EDIT:

It might be best to first set the ad zone id (module ID we are looking for) as a variable, then the campaigns assigned to that zone id then make sure both are approved.  Then if the result is empty/null, return the default module ID.  ugh - I'm getting confused now...

Edited By: mlipscomb
25-Mar-11 22:00:41

~Matt Lipscomb
Joomla! Leadership Team | Web Developer & Designer
http://www.usafreelancers.org/

mlipscomb
Web Developer
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

Sounds possible, but maybe not completely practical. I've been looking at the source code for the module, and I think that it would be easier to just edit that a little and piggyback on the logic in there.

Since I don't have the rest of the component, I can't test this, so it may take a little trial and error to get right. But here are some thoughts:

On line 1114 of helper.php in the adagency module, you'll see these lines:

if(!isset($output_this)) {$output_this='';}
$output_this.= $adv_here_bottom;
return $adv_here_top.$output_this;


replace these with:

if(!isset($output_this)) {$output_this='';}
global $ad_output1, $ad_output2;
$ad_output1 = $output_this;
$ad_output2 = $adv_here_top.$output_this.$adv_here_bottom;
return $ad_output2;


This is just to capture the output from the ads and store it in a global so we can retrieve it in MetaMod.

We store the actual ad output separately from the final output that includes the "advertise here" HTML. You might want to make MetaMod decisions based on whether there's "advertise here" text, independently of the other ad output.

So in MetaMod you should be able to do the following:

global $ad_output1, $ad_output2;
if (isset($ad_output1) and $ad_output1 != "") return XXX; // if an ad was displayed
return YYY; // if no ad was displayed


Replace $ad_output1 in the "if" condition with $ad_output2 if you want to include the presence of the "advertise here" text.

I'll be very interested to know if this works! If you are using MetaMod Pro there may be some possible hiccups due to the fact that the MetaMod may be calculated before the AdAgency module. So if this doesn't work, turn off the MetaMod Pro plugin and see if that makes it work. If that makes it work then please let me know and I'll suggest a slightly different way to approach it.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

That would work with only one ad on the page, but not multiple ones, right?  As it would be resetting that global variable.

I'll PM you with a bit more.

~Matt Lipscomb
Joomla! Leadership Team | Web Developer & Designer
http://www.usafreelancers.org/

mlipscomb
Web Developer
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

Ok, it's not too hard to modify what I wrote earlier to support multiple modules. The module knows its own id number, so we can use that in the variables.

So this is the new replacement text in the helper class:

if(!isset($output_this)) {$output_this='';}
global $ad_output1, $ad_output2;
if (!is_array($ad_output1)) $ad_output1 = array();
if (!is_array($ad_output2)) $ad_output2 = array();
$ad_output1[$module->id] = $output_this;
$ad_output2[$module->id] = $adv_here_top.$output_this.$adv_here_bottom;
return $ad_output2[$module->id];


Then in MetaMod:

$check_module = AAA; // replace AAA with the id of the advert you want to test
global $ad_output1, $ad_output2;
if (isset($ad_output1) and @$ad_output1[$check_module] != "") return XXX; // if an ad was displayed
return YYY; // if no ad was displayed


I think that should work...

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

Perfect - it worked very well.  I've sent iJoomla the adjusted file so hopefully they will include it in the next release.

Thanks again for all your help!

~Matt Lipscomb
Joomla! Leadership Team | Web Developer & Designer
http://www.usafreelancers.org/

mlipscomb
Web Developer
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

Hey thanks for passing it on to the iJoomla people. I wouldn't be surprised if they wanted to tackle this in a different way... but as long as you can query the results from outside their own module, then I am sure we can work with it.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod Pro with iJoomla AdAgency for Localized Pages

So I have a new addition to this....

The need is to go a bit further and only show the modules if it is on a certain article and additionally only if there is an ad available.  Here's what I put in, and it *is* returning the correct module - but not checking to see if it's empty and then displaying the fallback module.

Any clue what I did wrong?

Code:

$check_calgary = 322; //Calgary Ad ID for this position

$check_toronto = 391; //Toronto Ad ID for this position
$check_torontowest = 399; //Toronto West Ad ID for this position
$check_edmonton = 407; //Edmonton Ad ID for this position
$check_halifax = 415; //Halifax Ad ID for this position
$check_lethbridge = 423; //Lethbridge Ad ID for this position
$check_saskatoon = 431; //Saskatoon Ad ID for this position
$check_kitchenerwaterloo = 439; //Kitchener Ad ID for this position
$check_vancouver = 447; //Vancouver Ad ID for this position
$check_victoria = 455; //Victoria Ad ID for this position
$check_ottawa = 463; //Ottawa Ad ID for this position
$check_nsne = 471; //NSNE Ad ID for this position
$check_scarborough = 479; //Scarborough Ad ID for this position

global $ad_output1, $ad_output2; //Reads the ad output

if ($content_genius->check("article_id = 1198")
  and !(
    isset($ad_output1) and @$ad_output1[$check_calgary] != ""
    )
   ) return $check_calgary;

if ($content_genius->check("article_id = 1197")
  and !(
    isset($ad_output1) and @$ad_output1[$check_toronto] != ""
    )
   ) return $check_toronto;

if ($content_genius->check("article_id = 1196")
  and !(
    isset($ad_output1) and @$ad_output1[$check_torntowest] != ""
    )
   ) return $check_torntowest;

if ($content_genius->check("article_id = 1195")
  and !(
    isset($ad_output1) and @$ad_output1[$check_edmonton] != ""
    )
   ) return $check_edmonton;

if ($content_genius->check("article_id = 1194")
  and !(
    isset($ad_output1) and @$ad_output1[$check_halifax] != ""
    )
   ) return $check_halifax;

if ($content_genius->check("article_id = 1193")
  and !(
    isset($ad_output1) and @$ad_output1[$check_lethbridge] != ""
    )
   ) return $check_lethbridge;

if ($content_genius->check("article_id = 1192")
  and !(
    isset($ad_output1) and @$ad_output1[$check_saskatoon] != ""
    )
   ) return $check_saskatoon;

if ($content_genius->check("article_id = 1191")
  and !(
    isset($ad_output1) and @$ad_output1[$check_kitchenerwaterloo] != ""
    )
   ) return $check_kitchenerwaterloo;

if ($content_genius->check("article_id = 1190")
  and !(
    isset($ad_output1) and @$ad_output1[$check_vancouver] != ""
    )
   ) return $check_vancouver;

if ($content_genius->check("article_id = 1189")
  and !(
    isset($ad_output1) and @$ad_output1[$check_victoria] != ""
    )
   ) return $check_victoria;

if ($content_genius->check("article_id = 1188")
  and !(
    isset($ad_output1) and @$ad_output1[$check_ottawa] != ""
    )
   ) return $check_ottawa;

if ($content_genius->check("article_id = 1187")
  and !(
    isset($ad_output1) and @$ad_output1[$check_nsne] != ""
    )
   ) return $check_nsne;

if ($content_genius->check("article_id = 1131")
  and !(
    isset($ad_output1) and @$ad_output1[$check_scarborough] != ""
    )
   ) return $check_scarborough;


return 347; //Returns a ROS Ad if primary ad is empty

~Matt Lipscomb
Joomla! Leadership Team | Web Developer & Designer
http://www.usafreelancers.org/

mlipscomb
Web Developer
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Total Posts Today:
1
User Info:
 
Total Users:
10075
Newest User:
rsker57
Members Online:
0
Guests Online:
268

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked