1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

DRUPAL: Put Adsense in FIRST POST of a forum topic?

Discussion in 'Drupal' started by Tearabite, Apr 21, 2007.

  1. #1
    Does anyone know how to place Adsense (or anything, really) in the first post of a forum-topic in Drupal? I have Googled and read all over the support at Drupal.org and can't find the answer anywhere. I can't use the "adsense" module, so I need to be able to do it by modifying my node-forum.php .

    anyone that comes up with a way that works gets my everlasting appreciation :rolleyes:
     
    Tearabite, Apr 21, 2007 IP
  2. 802networks

    802networks Guest

    Messages:
    132
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    in node.tpl.php:

    <?php if(!$page&&($id==1||$id==3)): ?>
    [INSERT ADSENSE CODE HERE]
    <?php endif; ?>

    Chaange id to be whatever post # on the front page you want the google ad displayed after. i.e. here it would place the adsense code after the 1st and 3rd articles on the front page.
     
    802networks, Jun 4, 2008 IP
  3. Tearabite

    Tearabite Prominent Member

    Messages:
    4,629
    Likes Received:
    429
    Best Answers:
    0
    Trophy Points:
    300
    #3
    but.. i dont want it on the front page.. i want it to be after the first post of a forum topic.. as described in my original post..
    :confused:
     
    Tearabite, Jun 4, 2008 IP
  4. Petey

    Petey Peon

    Messages:
    68
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi Tearabite,

    Just for clarification. Do you want to put adsense after the first title in a list of forum threads or after the first post inside a forum thread?

    Petey
     
    Petey, Jun 6, 2008 IP
  5. Petey

    Petey Peon

    Messages:
    68
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Just noticed the start date of this thread :D

    I think that only the OP is formatted using the node-forum.tpl, replies are formatted using the comment.tpl. So you can simply add adsense to the template by changing:

    <div class="content">
    <?php print $content; ?>
    </div>

    to

    <div class="content">
    <?php print $content . "ADSENSE STUFF" ; ?>
    </div>

    BUT, this adds the adsense code AFTER the breadcrumb link to the next forum topic. That might not look too pretty.

    If you want to add it BEFORE the breadcrumb link then you have to make a change to the forum.module.

    Search for the "theme_forum_topic_navigation" routine and change the first line:

    from:
    $output = '';

    to:
    $output = 'ADSENSE STUFF';

    This displays your adsense stuff at the end of the OP and ahead of the breadcrumb. Only downside is that you've changed a core module to do it.

    Petey
     
    Petey, Jun 6, 2008 IP
  6. Tearabite

    Tearabite Prominent Member

    Messages:
    4,629
    Likes Received:
    429
    Best Answers:
    0
    Trophy Points:
    300
    #6
    Thanks Petey - I'll give both of these a try.. and yes, this IS a very old topic.. but still never found a good/working answer..
     
    Tearabite, Jun 6, 2008 IP