News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Google AdSense in SMF, various positions...

Started by Moonray, September 25, 2005, 11:46:56 PM

Previous topic - Next topic

Rumbaar

@saquib some themes are very different to the CORE theme so you'll have to try and use your best judgement to find the correct location for your specific theme.  Take a look at how it's positioned in the CORe theme and then try and work it out for your custom theme.  You might be able to ask in the themes specific comment/support thread for additional help from the author.

@paypalcommunity for your needs have you looked at the Ads Management mod, I think it has the ability to control the location of ads and you'll be able to position it in headers, footers and message posts.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

neforum

Quote from: spytrdr on December 03, 2007, 07:05:07 PM
Quote from: nitins60 on August 22, 2007, 04:46:54 AM
This s very simple trick to show ads on each and every page at the bottom of the page. Remember i m newbie to php, just i tried trial & error method!

open index.template.php file of any theme
find

//Show valid logos and Powered by .......

now just insert this code just above it

echo '
//Your Google Adsense code
';


that's it :P

This is a better positioning:

   // Show the menu here, according to the menu sub template.
   template_menu();

echo '
<div align="center">
YOUR GOOGLE SCRIPT HERE
</div>
';

   // The main content should go here.
   echo '
   <div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">';
}

Hey, thanks for that. I've now got Google Ads nestling just under the menu at the top of my forum, and they blend VERY well.  :)

http://www.neforum2.co.uk/smf [nofollow]
North East Forum [nofollow] - For North East England

KEA

#162
I may have missed the answer to my question so forgive me in advance. 

I have SMF1.1.4 with the add mod isntalled.  I have entered the appropriate code from Google Adsense and I am able to see my ad on every page as I want but it shows up on the far left under the menu. 

Also when you click on the add it takes you out of the forum.  How do you make the add a link so it doesnt take the members out of the forum when clicked?

How can I get the adds to center on the page instead of showing up on the far left.

Also, how can I show more than three adds?

I am using the core theme. 

www.sawmillandtimberforum.com

Rumbaar

I think your question is more of a Ads Management mod configuration question KEA?
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

KEA

OK, Ill try there.  I figured it would be best here since it was specific to Google Adsense but Ill post it on the Ads Man. mod topic.

Thanks

Rumbaar

Well some of it might be specific to Google Adsense (ie open new link in new tab/browser) but the positioning and layout you are after is part of the Ads Management mod system.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

pp08

#166
hi Moonray, i am a new user, i posted how to add google adsense on my forum question and one of the smf specialist gave me this link... can you provide me exact code for my theme plz. and instruction on what i have to do step by step. when it comes to these things i dont know much close to nothing actualy so i dont mess up my forum so please give me detailed info on what file i have to edit and what part. also what part i have to change and put my google code thank you in advance

i am using smf 1.1.2 and theme "ancient and rusted" if i have to upgrade to smf 1.1.4 will the theme and the codes work with it?

rancitis

Hi guys!. I would like to know how to integrate an announcer at the first post each topic. I want to be seen as follows:  ;)

[nofollow]

I have installed the "Ad Management mod" but doesn't have this option. What should I do modify the code in the site to integrate this position ad?. I'm using smf 2.0 beta 3. I'm sorry for my bad english  :P.

Cheers.

snork13

#168
Quote from: rancitis on March 23, 2008, 07:53:23 AM
Hi guys!. I would like to know how to integrate an announcer at the first post each topic. I want to be seen as follows:  ;)



I have installed the "Ad Management mod" but doesn't have this option. What should I do modify the code in the site to integrate this position ad?. I'm using smf 2.0 beta 3. I'm sorry for my bad english  :P.

Cheers.

I run an ad just before the first post. Search for


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


in Display.template.php in your theme directory. You will need to change it to something like this


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

AD SCRIPT GOES HERE

}


Here is the complete idea of what I'm doing, I don't use the ad management mod at all. I tweaked a few things to display to only regular members and guest. In my signature is a link to the forum, which will show you the results. The code could be cleaned up a little, just haven't had time :P


// Show the message anchor and a "new" anchor if this message is new.
if ($message['id'] != $context['first_message'])
echo '
<a name="msg', $message['id'], '"></a>', $message['first_new'] ? '<a name="new"></a>' : '';

echo '
<table width="100%" cellpadding="3" cellspacing="0" border="0">';
       
        if ($message['id'] == $context['first_message'])
     
   {
   
        $allowed_group = 0; // The group ID which will see the button.
        global $user_info;
        if (in_array($allowed_group, $user_info['groups']) || ($context['user']['is_guest'])) {
                echo '
                <tr><td style="padding: 0px 0px 1px 0px;">
                    <table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr><td align="center" class="smalltext windowbg" ><br />';
         

                echo '<script type="text/javascript"><!--amazon_ad_tag = "*******";  amazon_ad_width = "728";  amazon_ad_height = "90";//--></script>
                    <script type="text/javascript" src="http://www.assoc-amazon.com/s/ads.js"></script>
                    <br /><br /></td></tr>
  </table>
</td></tr>';
   
}
}
       
        echo'
<tr><td class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', '">';


-snork13
Mods
Please DO NOT PM me with requests for individual support, but post your questions and concerns in the appropriate section of the forum where other users can benefit from them as well. Thank you.
I have been super busy as of late. Working on updates to all my modifications for 2.0.1

rancitis

Thanks snork13  ;), but this will not be integrating the announcement in the manner indicated and the structure of Display.template.php in smf 2.0 is different. The author of the"Ad Management mod"  would have to take into account how much this position because it is very important these location


SleePy

2.0 looks the same to me.

        // Show the message anchor and a "new" anchor if this message is new.
        if ($message['id'] != $context['first_message'])
            echo '
        <a name="msg', $message['id'], '"></a>', $message['first_new'] ? '<a name="new"></a>' : '';

        echo '
        <table width="100%" cellpadding="3" cellspacing="0" border="0">
            <tr><td class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', '">';
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

vojailic

Any idea how to achive this in Recent posts?

Tosyne

Please i have not being able to add adsense on my forum.

Kindly assit.

Thanks

hxxp:faithfulsnetwork.com/index.php [nonactive]
hxxp:www.faithfulsnetwork.com/ [nonactive]
hxxp:www.freelancez.blogspot.com/ [nonactive]

happybear

I've just realized that I'm not alowed to post a topic so I'm posting my question here.

Can I add google adsense to my private forum i.e. only accessible to members who have signed in? I'm trying unsuccessibly to add it to my forum and it's still not showing.

This is so frustrating until I realize that it could be because my forum is set to private browsing. Anyone can help?


SleePy

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

neich

Quote from: SleePy on July 30, 2008, 01:31:44 AM
We do have a couple ad mods that might help you out if they are easier to install :)
http://custom.simplemachines.org/mods/index.php?mod=1216
http://custom.simplemachines.org/mods/index.php?mod=255

Is there any way to apply the 2nd mod (ads management) to a theme different to the default one ?

Thanks

iGraphiX

Hi lads, this is a way too long post, and I was wondering if I can make it longer. Hehe, just kidding.
I'm a noob but I hope this helps:


View full-size image here: hxxp:i37.tinypic.com/n2dcvq.png [nonactive]

I'm using SMF 1.1.6.
In order to see what's in the screenshot you have to do the following modifications in the default theme folder, file to edit: Display.template.php

1. For the top of post ad unit:

Find this code:

// Now show how many guests are here too.
echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
</td>
</tr>';
}

echo '
</table>';


And right after it add:

//Google Adsense
   echo '
   <tr><td style="padding: 1px 1px 0 1px;">
   <table width="100%" cellpadding="3" cellspacing="0" border="0">
   <tr><td class="windowbg">
   <div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-YOUR_ADSENSE";
/* blog_bottom */
google_ad_slot = "6779400012";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
   </div>
   </td></tr></table></td></tr>';
//End of Google Adsense


2. To display AdSense unit after the first post:

Find this code:

// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']))
echo '
<hr width="100%" size="1" class="hrcolor" />
<div class="signature">', $message['member']['signature'], '</div>';

echo '
</td>
</tr>
</table>
</td></tr>
</table>
</td></tr>';


And right after it add this code:

//Google Adsense
if ($message['id'] == $context['first_message'])
   echo '
   <tr><td style="padding: 1px 1px 0 1px;">
   <table width="100%" cellpadding="3" cellspacing="0" border="0">
   <tr><td class="windowbg">
   <div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-YOUR_ADSENSE";
/* blog_bottom */
google_ad_slot = "6779400012";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
   </div>
   </td></tr></table></td></tr>';
//End of Google Adsense


Now it easy to understand that in order to correctly display Google AdSense units in any version of SMF forums, in any position or alignment, just see this code and place it where you think it might bring some impressions:

   
//Start Google Adsense   
echo '
   <tr><td style="padding: 1px 1px 0 1px;">
   <table width="100%" cellpadding="3" cellspacing="0" border="0">
   <tr><td class="windowbg">
   <div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-YOUR_ADSENSE";
/* blog_bottom */
google_ad_slot = "6779400012";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
   </div>
   </td></tr></table></td></tr>';
//End of Google Adsense


PS. Don't forget to insert your Publisher ID fron AdSense :)

Rumbaar

Quote from: neich on August 28, 2008, 10:57:45 AMIs there any way to apply the 2nd mod (ads management) to a theme different to the default one ?
Thanks
Yes, just like any mod you just manually add the code to any of the applicable template files in your custom theme.

Manual Installation of Mods
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

krish227

Hey does dis tutorial helps for version 1.1.6 & custom theme. my forum has a custom theme Metallistic. So can ur tutorial help my forum?

Advertisement: