Hi,
I had a requirement that the ads need to target a path, so I created a module that extends your module to allow a user to target an advert by path within a group. I created a sandbox project for it here http://drupal.org/sandbox/thetoast/1473012 , any thoughts on putting something like that into your module? I've added the functionality to include a path, but once my client sees it they're probably going to want to have an exclude path option as well which I haven't implemented in my sandbox module (yet).

Comments

minnur’s picture

Since this SimpleAds created in the system as a block you may specify paths there and display that block only for certain user roles and paths. have you tried this approach ?

Thanks.

thetoast’s picture

Yeah I thought of that approach initially, but then every targeted path advert with a single block would mean giving the users access to manage these blocks and that isn't acceptable on the project I'm working on, as creating ads would be the only thing the marketers would be able to do on the site.

The user would have to manage which blocks need to hide and show if only one block of ads will ever be displayed on the site, and they expect to be using quite a few targeted ads. This is for the site of the British Film Institute http://beta.bfi.org.uk/ , so they'll be targeting many pages with ads.

The new build of that site is also going to be using the context module so the blocks are controlled from context which means the block settings are useless.
It wouldn't be a problem for me if you didn't add something like that into your module, as my module is handling my itch without having to hack your module. I would just need to watch out for any function name or functionality changes you might make.

But I thought I'd just put it out there to see if that might be something others might need.

Apart from that, thanks for creating the simpleads module, it's very simple to use for my very clever users ;-P .

minnur’s picture

Status: Active » Postponed
annikaC’s picture

I recently needed to do this - here's my solution. (2.x dev)

I use hook_views_post_execute to get the view results. I created a field(textarea, plain text) for the user to enter paths, as you would in block visibility settings. I added this field to the SimpleAds view, ticking 'Exclude from display' so it still shows up in the view object. Then I use the drupal_match_path function to see if the current path matches that in the results. If it doesn't, the ad isn't shown on that page.

function simpleads_views_context_path_views_post_execute(&$view) {
  if ($view->name === 'advertisement_blocks' && $view->current_display === 'block_1') {
    if(request_path() === '' || request_path() === 'node') {
      $path = variable_get('site_frontpage', 'node');
    }
    else {
      $path = request_path();
    }
    // Unset results in group if they don't match path in ad
    foreach ($view->result as $key => $result) {
      if (isset($result->field_field_path_filter[0])) {
        if (!drupal_match_path($path, $result->field_field_path_filter[0]['raw']['value'])) {
          unset($view->result[$key]);
        }
      }
    }
  }
}

Hope this helps some of you out there! I didn't fancy creating a ton of blocks for each of the pages I needed a specific ad on.

Proteo’s picture

Actually this would be a very useful feature to have "by default". I'm creating a large web portal that handles several dozens of sections. Its bussines model relies on selling ads that are displayed in a defined set of sections (sometimes just one, sometimes two or three) of the site.

Under the current model (based on blocks) this is possible but it requires to create a lot of blocks. Since each page contains 4 different zones to place ads, managing 10 different sections would require to create 40 different blocks to cover all posibilities (and the site has more than 60 sections).

On the other hand, if I had the possibility of defining the target path directly in the ad I would need only 5 different blocks, one for each zone in the page, since the path restriction would be handled by the ad itself.

minnur’s picture

Issue summary: View changes
Status: Postponed » Closed (won't fix)