• Welcome to Simple Machines Community Forum. Please login or sign up.

Adsense within first post of thread in smf 2.0 specially the core theme

Started by aamjad2001, September 06, 2011, 05:45:53 PM

Previous topic - Next topic

aamjad2001

Now you can have a small, rectangular adsense ad appear within and directly beneath the content of the first post in each thread  specially in the core theme.

You can try this approach:
Find in Display.template.php:

<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>


Replace the above with:

<div class="inner" id="msg_', $message['id'], '"', '>';
                 if ($message['id'] == $context['first_message'])
      echo '
                        <div style="float:right; width:270px;">
                        <script type="text/javascript"><!--
                        google_ad_client = "pub-xxxxxxxxxxxxxxx";
                        /* 250x250, created 9/07/11 bforum text */
                        google_ad_slot = "xxxxxxxxxxxx";
                        google_ad_width = 250;
                        google_ad_height = 250;
                        //-->
                        </script>
                        <script type="text/javascript"
                        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                        </script></div>';
      echo '   
               ', $message['body'], '</div>


You can see the demo here:
http://www.baqaians.com/bforum/general-physician-desk/myths-about-the-menstrual-periods/




glennk

is this possible for the bigger banners ? I want to put the large adsense banner in the first post only ??

NanoSector

@glennk: Yes, that should be possible :)

Also, I don't want to ruin anyone's experience, but this can also be done with Ad Management Mod, AFAIK. That's a bit simpler for most users, but if you just want it there without installing big mods you can indeed use this :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."


fifacluborg

@aamjad2001 - Thank you so much for this tutorial... really useful! :)

chimbocool

i use Ad Management Mod before i don't like and the ads appear at the top of the post not in the post

and @aamjad2001 - Thank you so much for this tutorial... really useful! 

-------------------------------------

dead4ever.com


ApplianceJunk

Nice tip.

I started using http://www.smfhacks.com/ad-seller-pro.php some time ago.
It lets you create custom ad locations in the template.

It has also help me learn how to manually edit templates too.

jonyparks


PSPguru

I would be very satisfied with the free mod for adsense, thank you for the tutorial

LebronJamson

This works just fine. But I would like to put the ad between first and second post, not inside the first. How do I do that?

Ad management mod doesn't work for me, it shows ads only at the top and bottom of the page. Only with this code I was able to put the ad into the post. But I need a little tweek. Thanks in advance, guys. (I have SMF 2, default Core theme)

dimspace

is it possible to modify this for guests only.

i am gradually switching to ad free forum for members

NanoSector

Quote from: dimspace on February 10, 2013, 10:34:07 PM
is it possible to modify this for guests only.

i am gradually switching to ad free forum for members
In the "replace with" code in the first post,

Replace:
if ($message['id'] == $context['first_message'])

With:
if ($message['id'] == $context['first_message'] && $context['user']['is_guest'])
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

dimspace

Quote from: Yoshi2889 on February 11, 2013, 05:30:46 AM
Quote from: dimspace on February 10, 2013, 10:34:07 PM
is it possible to modify this for guests only.

i am gradually switching to ad free forum for members
In the "replace with" code in the first post,

Replace:
if ($message['id'] == $context['first_message'])

With:
if ($message['id'] == $context['first_message'] && $context['user']['is_guest'])

cheers yoshi.

most of my ads i just use simple portal, i dont have many anyway, just two the right in normal mode, or header and footer in mobile mod, but about five months ago i seperated the guest and member ads so i could track each one.

guests are about 70% of my revenue so im not far from having ad free forum for members with the guests funding the server.

NanoSector

That's awesome :)

Do keep in mind that if you get less guests you get less income, so you should be prepared for that.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."



knightofdoom

Glory is fleeting, but obscurity is forever.
Web Designer Sri Lanka

karde

Thank you, this is great way to add ad in thefirst post without a mod.
come and join us on UK jobseekers [nofollow] forums.

ryan_dwight

how to make this thing work on specific board only?

because the ad management board doesnt work on "Display ads within posts"

or i just dont know how to do it.



drfun

Quote from: ryan_dwight on May 13, 2013, 05:48:53 AM
how to make this thing work on specific board only?

because the ad management board doesnt work on "Display ads within posts"

or i just dont know how to do it.
ECLIKS -Global Online community for Questions and Answers

Advertisement: