Inserting Adsense into Nodes in 6.x

superflyman - August 17, 2008 - 04:51
Project:Adsense Injector
Version:5.x-2.5-1
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

As there is yet no version of this for 6.x I was wondering how to go about inserting the appropriate code into the node.tpl.php file to show ads after the 1st paragraph in Nodes in the full page view (non-teaser). I guess I'm just looking for whatever generic code I need to paste and where to paste it. The php code is the standard template:

<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
    <?php if ($picture) {
      print
$picture;
    }
?>

    <?php if ($page == 0) { ?><h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2><?php }; ?>
 
  
    <div class="content"><?php print $content?></div>
  <div class="postmeta"><span class="submitted"><?php print $submitted?></span> <span class="taxonomy"><?php print $terms?></span></div>
    <?php if ($links) { ?><div class="links"> <?php print $links?></div><?php }; ?>

  </div>

Any help would be greatly appreciated. I have been struggling with this for weeks...

#1

superflyman - August 17, 2008 - 14:03
Category:task» support request

#2

grateful_drupal_user - August 17, 2008 - 15:30
Status:active» postponed

This is a tricky bit. The definition of a 'paragraph' is somewhat vague. What is a paragraph? Some seem to think that any bit of rendered html ending in </p> is a paragraph, but I think there's more to it than that.

In any case... If you search some of the older issues for adsense_injector, you will find some patch submissions for PHP5 only that attempt to do this. See: http://drupal.org/node/141096 -- I was unwilling to go PHP5-only on this module, so, the patch is unacceptable for this project at this time. You might find the techniques helpful - the patch was very specific to a particular need but you might be able to extract some useful information.

Also, the ads module claims to be able to do exactly what you want, so you could examine that modules source code for inspiration.

 
 

Drupal is a registered trademark of Dries Buytaert.