Ads per role

Manonline - April 23, 2009 - 15:54
Project:Advertisement
Version:6.x-2.0-rc1
Component:ad_channel module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Hi! I have a site which is based on roles to identify the user's profile who is surfing it.

First I created different ads groups for each role and I put the blocks one below the other, but if one user has two or more roles, he views two or more ads one below the other.

Then I installed the Nodeaccess module. I thought if I created only one group for all the ads and I grant view permissions for each role in each ad, the 'ad block' would displays randomly the permited ads. This module works perfectly with all content types, but not with Advertisment Type.

I didn't explore the ad module deeply because is huge! So I don't know if this feature already exists, but it will be a great feature!

My idea:

In Ads Creation Form add some checkboxes with the roles (defined at ads settings in administration page). The selected roles must be able to see the ad. If none role is selected, all roles must be able to see the ad.

thanks for taking time to read me :)

#1

Jeremy - April 23, 2009 - 23:14
Component:ad module» ad_channel module

This is not currently possible. It believe it would be best added as a feature to the ad_channel module, I'll leave it open to review at some point if I find the time - patches welcome.

#2

pingu2k4 - May 8, 2009 - 15:59
Status:active» needs review

Hi, i think i understand what your trying to do, and if i do, i wanted to do the same thing. ive done very little php work, but have programmed in other languages. Anyway, this is working for me...

in whatever .tpl.php files i want to use it in, i place an ad as follows:

<?php
 
global $user;
  if (!(
in_array('adfree', $user->roles)))
  {
    print
ad(NULL, 1, array('nids' => '66')); ;
  }
 
?>

this particular example will show the advert unless the uesr has been assigned to the adfree role. and it will show add at node id 66.
To display an ad to a prticular role instead of to all but a particular role, use:

<?php
 
global $user;
  if ((
in_array('ads', $user->roles)))
  {
    print
ad(NULL, 1, array('nids' => '66')); ;
  }
 
?>

where node id 66 is the advert you want to show, and ads is the user role to show it to.

alternatively, im assuming you can create a new html ad, and put the following:

<?php
 
global $user;
  if ((
in_array('ads', $user->roles)))
  {
    print [
ad code here]
  }
 
?>

replacing the [] with your ad code. should also work with the first example excluding it from a certain role.

Hope this helps...

#3

tobiberlin - June 13, 2009 - 16:44
Assigned to:Anonymous» tobiberlin

Hi Pingu,

thank you very much for this code but I feel as if this takes much of the flexibility of the module - for example if I want to choose embedded ads which are automatically embedded in content after the Xth paragraph and where I can choose after which paragraph.

Is there anyone working on this issue?

Greez,
Tobias

#4

tobiberlin - October 10, 2009 - 09:42
Assigned to:tobiberlin» Anonymous
 
 

Drupal is a registered trademark of Dries Buytaert.