Hello,

I need to be able to display related ads on each page request. E.g. I have two advertising spaces, one in the header, one in the right menu.

On each page request, I need both advertising spaces to show an ad for the same company, even though they'd be different ads (because the file size is different). I don't want Sony up the top, and Virgin on the right for example.

Can this be achieved in any way?

If not, if I was going to develop a custom addon, what's the best way to go about it?

Thanks,

Comments

aidanlis’s picture

Category: support » bug
StatusFileSize
new31.59 KB
new46.35 KB

I'm moving this into the bug report category in the hope of getting a response after 20 days.

Using the channels module, I can categorize the ads into a pattern. One channel per company, one channel per region. See the screenshots attached to see what I mean.

Now, I guess what I need to do is create a custom module that does something along the lines of: add a button to the ad per-block configuration saying "display ads in the same channel as [region], where the channel belongs to [category]"

This would allow me to create three blocks, for example. The first block in region1 would be "region: null, category: null". The second block would be "region: region1, category: companies". Etc.

This works from a UI perspective (i think).

From an implementation perspective, once the first block is displayed the submodule could modify the probability of the other ads in that required channel.

Is this the best solution forward? I'm happy to do the coding, a few pointers in the right direction would be good.

aidanlis’s picture

StatusFileSize
new72.75 KB

The previous idea had some problems, and added complexity.

If I create a group for each region that I want to display ads in, and a channel for each company, then the question becomes "How do I display ads in the same channel on each page view".

aidanlis’s picture

I've modified the ad module to do this. I realise it's a nasty hack, and it's incompatible with the way the rest of the modules work, but it does solve my problem for the time being.

This bypasses all the caching, which means it can't be used on a heavily loaded server either.

I'd love the authors ideas on how to do this properly ...

// Line 1280 of the ad.module, in hook_block('view');

      if (!isset($GLOBALS['ad_brand_channel'])) {
        // Grab a random node from the current ad group
        $nid = db_result(db_query("SELECT n.nid FROM node n LEFT JOIN term_node tn ON n.nid = tn.nid WHERE tn.tid = %d ORDER BY RAND() LIMIT 1", $delta));
        
        // Grab and save the nodes channel for the rest of this page request
        $channel = db_result(db_query("SELECT chid FROM {ad_channel_node} WHERE nid = %d LIMIT 1", $nid));
        $GLOBALS['ad_brand_channel'] = $channel;    
      }
      else {
        // Grab a random node from the current ad group and the previous ad's channel
        $channel = $GLOBALS['ad_brand_channel'];
        $nid = db_result(db_query("SELECT n.nid FROM node n LEFT JOIN term_node tn ON n.nid = tn.nid LEFT JOIN ad_channel_node acn ON n.nid = acn.nid WHERE tn.tid = %d AND acn.chid = %d ORDER BY RAND() LIMIT 1", $delta, $channel));
      }
      if (!empty($nid)) {
        $options['nids'] = $nid;
      }
anonymous07’s picture

I see you are having a conversation with yourself here ... I thought I would subscribe so you can feel like someone is listening ... lol

Seriously though, I am interested in this also (though, admittedly, not as much as getting the channels to work right).

Cheers

nilofar123’s picture

hi,
i want to know that how i place only one ad on only one page,
because on my website i am facing problem with advertisement when i refresh page the advertisement changes
i don't want to change ad when i refresh the page .
i want that ad becomes constant on page whatever page refresh or not

lrwebks’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is EOL and no longer supported. Closing this as outdated for that reason. Thanks for your contribution!