I wanted to see if anyone could tell me how to insert code within each node, or on certain nodes of my choice, but not have that code display on the manin category pages from which the node came from.

More specifically, I want to insert a small amount of code for certain nodes created to disply advertising blocks. These would be floated right within the <div> tag controlling the node layout.

I want to use something like this:

<div class="adverbox"><a href="http://www.siteabou widgets.com">Discount Prices on Widgets</a><br />
<p>Order Widgets today and receive same day delivery.</p>
</div>

The above "adverbox" would be floated right within the node layout, which works fine and looks good.

The only problem is when you go back to the main category page that the node belongs too you see the same box floated right there as well, which looks funky and kind of breaks the stacking layout of each of the nodes within that category.

Can anyone give any examples of an alternate way of displaying these advertising boxes without then displaying on the category pagesdoing this?

Thanks much!!
Internet Marketing Blog

Comments

nevets’s picture

It sounds like you only want to show the ads when viewing the complete node. You could write a simple module that implements the view option. Since you can tell if is a $teaser or $page view you can limit when the ads get inserted. The code for the hook might look like

<?php
yourmodule_nodeapi(&$node, $op, $teaser, $page) {
  if ( $page && $op == 'view' ) {
    $node->body = 'Your ad here' . $node->body;
  }
}
?>
trueMarketing’s picture

Hi Nevets. thanks for your response!

Yes, I would only want the ads to appear on the node page alone, not in the teaser location. Sorry for the inexperience, but would your example php snippet need modifying to work in the node page only and how would I go about inserting/trying it, i.e. where would I put the snippet? I'm guessing it goes in the open field where you edit the particular node and I simply insert the php code there and click the radio button to allow for php code, right?

Also, where you have 'Your ad here' in the example you gave, what do I put in place of that?

Again, sorry for the newbie questions - I'm just getting a grasp on Drupal and php...

Thanks again,

SEOPosition.com
SEO Company
Offering Pure CSS Design, Web Optimization & SEO Consulting

nevets’s picture

Lets say you are creating a module call nodeads, you would place the snippet in a file called nodeads.module (in the modules directory), changing yourmodule_nodeapi to nodeads_nodeapi. It should only show ads when the node is viewed by it's self.

In the simple case you would replace 'Your ad here' with the html in your original posting. You could also provide an adminstrative interface (nodeads_settings) that would allow you to set the text/html for the ad instead of hardcoding it.

trueMarketing’s picture

thanks Nevets,
I tried it and it worked pretty well. I'm using phpadsnew, so I may try to integrate that ad box within the particular node(s) to use the xml ads from phpadsnew.

Thanks again for the tips!

SEOPosition.com
Offering Pure CSS Design, Directory Submissions, & SEO Consulting

coupet’s picture

Banners
http://drupal.org/node/45294

search for 'phpadsnew' and see threads that reference the subject.

----
Darly