Genesis, Adrotate plugin and Maxmind Geotracking

Community Forums Forums General Discussion Genesis, Adrotate plugin and Maxmind Geotracking

This topic is: resolved

This topic contains 1 reply, has 2 voices, and was last updated by  cehwitham 10 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38609

    mathiasppc
    Participant
    Post count: 27

    Hi there,

    Have spent many hours now on trying to figure out how I can get these three working together. Would really appreciate any input/suggestions on how to tackle this.

    I think it can be done with either JS or PHP, the last one would require an external plugin like Exec-PHP.

    First of all, from a performance standpoint, is it bad to run PHP code inside posts, widgets etc?

     

    Here`s what I`ve got so far in JS:

    <code>

    `
    if (country_code==’US’)
    {
    document.write("[adrotate banner="1"]");
    }
    else
    {
    document.write("[adrotate banner="2"]");
    }
    
     
    
    `
    The problem is that outputing the shortcodes does not work. I`ve tried all combinations of using ' and ", but no luck!
    
     
    
    I could use PHP too. In that case I`m having problems with saving the variable country_code globally. I want to only run the code before the if-statement once (and not for every ad on my page).
    
     
    
    <code>
    
    <?php
    require_once(“geoip.inc”);
    $gi = geoip_open(“GeoIP.dat”,GEOIP_STANDARD);
    $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
    geoip_close($gi);
    if($country_code == ‘US’ || $country_code == false)
    {
    echo adrotate_group(1);
    }
    else
    {
    echo adrotate_group(2);
    }
    ?>
    
    </code> 
    
     
    
    Again, would love any responses on this!
    
    Thanks in advance
    
     
    
    -Mathias
    
    http://energyinformative.org/genesis/
    #43711

    cehwitham
    Participant
    Post count: 396

    Hi Mathias,

    I would write the PHP code into a function then use a genesis hook to inset it into the right place. genesis_before_post for example.

    Chris


    Twitter: cehwitham Web: cehwitham.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.