I am looking for a possibility to display a banner code from banner.module or also the google adsense code automatic after every treaser !--break-- in articles and blog-entrys.

example:

some text some text some text some text

!--break--

banner or adsense-code (automatic displayed)

more text more text more text more text
more text more text more text more text

How can i realize that?

greetings from germany, holger

---
www.stnetwork.de
www.ebec.net

Comments

Uwe Hermann’s picture

Here's a simple patch for HEAD which adds some dummy text. More work needed for adsense etc. integration.

Index: node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node.module,v
retrieving revision 1.523
diff -u -p -r1.523 node.module
--- node.module 25 Aug 2005 21:22:00 -0000      1.523
+++ node.module 28 Aug 2005 01:41:49 -0000
@@ -478,7 +478,7 @@ function node_view($node, $teaser = FALS

   // Remove the delimiter (if any) that separates the teaser from the body.
   // TODO: this strips legitimate uses of '<!--break-->' also.
-  $node->body = str_replace('<!--break-->', '', $node->body);
+  $node->body = str_replace('<!--break-->', 'INSERT FUNNY ADS HERE', $node->body);

   // The 'view' hook can be implemented to overwrite the default function
   // to display nodes.

Uwe.
--
hermann-uwe.de | crazy-hacks.org | unmaintained-free-software.org

holger’s picture

Thank you, I did the changes like

// Remove the delimiter (if any) that separates the teaser from the body.
  // TODO: this strips legitimate uses of '<!--break-->' also.
  $node->body = str_replace('<!--break-->', '<?php if (module_exist('banner')) : ?><?php print banner_display(1); ?><?php endif; ?>', $node->body);

but i get this error :
Parse error: parse error, unexpected T_STRING in /www/htdocs/stnx/modules/node.module on line 487

The Banner group 1 exists.
I use Drupal 4.6.3 updated from 4.6.2

How can i fix the error?

greetings from germany, holger

http://www.ebec.net . . .
http://www.stnetwork.de . . .

holger’s picture

Micha from www.langmi.de have made the final the solution :

function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
  $node = array2object($node);

  // changed for banner-display after <--break--> command
  if (module_exist('banner')) { 
    $banner = banner_display(2); 
  }
  else {
    $banner = '';
  }

  $node->body = str_replace('<!--break-->', $banner, $node->body);

danke an Uwe und Micha :-)

http://www.ebec.net . . .
http://www.stnetwork.de . . .

stanleyb23’s picture

Im very happy to see a solution for this problem. I can see what this code is doing but im just starting to understand it.
My question..

Is there a way to use this script without the banner module and just put a script in for openads?
The script i want to use is something like this:

<script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://www.mijndomein.nl/rec/www/delivery/ajs.php':'http://www.mijndomein.nl/rec/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=3");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]>--></script><noscript><a href='http://www.mijndomein.nl/rec/www/delivery/ck.php?n=aa010421&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://www.mijndomein.nl/rec/www/delivery/avw.php?zoneid=3&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=aa010421' border='0' alt='' /></a></noscript>

I hope someone can helps me with formulating the script.

Thanks in advance,

Ralf

stanleyb23’s picture

Ok,

I almost did it but... i managed to get an openads code to look for a banner after the break.
The strange thing is when i add this code my search function and log in function doesnt work anymore.

There must be a way to insert this script but my knowledge of code is not enough to get it working.
I really hope someone can help me with this. I m using openads to put in google adsense or a banner when available. The advantage of working with openads is that i can manage all my advertising for all my drupal sites from 1 place.

This is what i did to get the banner after the break:
// $Id: node.module,v 1.776.2.19 2007/07/26 19:16:46 drumm Exp $

unction node_build_content($node, $teaser = FALSE, $page = FALSE) {
  // Remove the delimiter (if any) that separates the teaser from the body.


$mijn_js = '<script type=\'text/javascript\'><!--//<![CDATA[
var m3_u = (location.protocol==\'https:\'?\'https://www.mijndomein.nl/rec/www/delivery/ajs.php\':\'http://www.mijndomein.nl/rec/www/delivery/ajs.php\');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = \',\';
document.write ("<scr"+"ipt type=\'text/javascript\' src=\'"+m3_u);
document.write ("?zoneid=4");
document.write (\'&amp;cb=\' + m3_r);
if (document.MAX_used != \',\') document.write ("&amp;exclude=" + document.MAX_used);
document.write ("&amp;loc=" + escape(window.location));
if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
document.write ("\'><\/scr"+"ipt>");
//]]>--></script><noscript><a href=\'http://www.mijndomein.nl/rec/www/delivery/ck.php?n=ab83c427&amp;cb=INSERT_RANDOM_NUMBER_HERE\' target=\'_blank\'><img src=\'http://www.mijndomein.nl/rec/www/delivery/avw.php?zoneid=4&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=ab83c427\' border=\'0\' alt=\'\' /></a></noscript>';

$node->body = str_replace('<!--break-->', $mijn_js, $node->body);

Why is this giving troubles to the login and search function?

Pls help :)