Search code examples
openx

OpenX: Allowing banner links to use the host of the page the banner is being displayed on


My client has a website with many subdomains, each representing a different "client":

http://www.store.com <- Main store; also the default OpenX "Website" host in admin.
http://client1.store.com <- Client store
http://client2.store.com <- Client store
...
http://client222.store.com <- Client store

A lot of the banners are internal links. For those internal ads, they use relative URLs in that banner's "Destination URL" field, in hopes that the link will use the host of the page the ad is being displayed on. But to no avail, the ads seem to always use the host of the OpenX "Website" that that zone is connected to.

So for these local ads I need the host of the destination URLs to match the page the ads is being displayed on. Any suggestions?


Solution

  • The answer to this question was to set the Banner's URL to something like this:

    http://{currenthost}/shoes-half-off
    

    Then pass extra, custom variable currenthost into the invocation code.

    If the zone is in Local Mode

    Set the variable like this, somewhere before your call to view_local():

    $_REQUEST['currenthost'] = $_SERVER['HTTP_HOST'];
    $raw = view_local($what, $zoneid, $campaignid, // ...
    

    If the zone is in Javascript Mode

    Pass it into openx/www/delivery/ajs.php as a part of the GET string. Turn this:

    // ...
    if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
    document.write ("'><\/scr"+"ipt>");
    // ...
    

    Into this:

    // ...
    if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
    document.write ("&amp;currenthost="+window.location.href); // <-- Added
    document.write ("'><\/scr"+"ipt>");
    // ...