Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Niteblade on February 25, 2007, 09:47:21 PM

Title: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on February 25, 2007, 09:47:21 PM
Edit: 06-18-2007: I am re-installing my forum.

[Note]
I'm not "supporting" this modification. I got some help over at Webmasterstalks (http://www.webmasterstalks.com/general/adsense-at-the-bottom-of-the-first-post-t1071.0.html). Backup your files before you modify them. Please update this code with your adsense ID. All I did was put adsense inside its own <table> after I saw a </table> in the files that I modified.
[/note]

index.template.php -- Puts adsense on every page; useful if you use Tinyportal left and right blocks..


// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

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

// Begin Adsense on Index.
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;" class="windowbg">
<tr>
<td valign="top" width="85%" height="100%">
<div style="overflow: auto; width: 100%;" align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-728x90
google_ad_channel = "8891092745";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
';

// End of Adsense on Index.


BoardIndex.template.php -- Puts adsense on Board Index, before Info Center.

// Show the mark all as read button?
if ($settings['show_mark_read'] && !empty($context['categories']))
echo '
<table cellpadding="0" cellspacing="0" border="0" style="position: relative; top: -5px;">
<tr>
', template_button_strip($mark_read_button, 'top'), '
</tr>
</table>';
echo '
</td>
</tr>
</table>';
}

// Adsense before info center.
    echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
                        <td valign="top" width="85%" height="100%" class="windowbg2">
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al";
//2007-02-18: midessa-forum-468x15
google_ad_channel = "8866871717";
google_color_border = "423935";
google_color_bg = "423935";
google_color_link = "D0D0D0";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
<td valign="top" width="85%" height="100%" class="windowbg">
<br />
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<br />
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-468x60
google_ad_channel = "8764535480";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br><br />
</div>
<br />
</td>
</tr>
</table>';
// End Adsense before info center.

// Here's where the "Info Center" starts...
echo '<br />
<div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
<div class="catbg" style="padding: 6px; vertical-align: middle; text-align: center; ">
<a href="#" onclick="shrinkHeaderIC(!current_header_ic); return false;"><img id="upshrink_ic" src="', $settings['images_url'], '/', empty($options['collapse_header_ic']) ? 'collapse.gif' : 'expand.gif', '" alt="*" title="', $txt['upshrink_description'], '" style="margin-right: 2ex;" align="right" /></a>
', $txt[685], '
</div>
<div id="upshrinkHeaderIC"', empty($options['collapse_header_ic']) ? '' : ' style="display: none;"', '>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';


Display.template.php -- Puts adsense after EVERY first post.

// 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>';

// Adsense after first post.
if ($message['id'] == $context['first_message'])
{
    echo '
        <tr>
<td style="padding: 0px 1px 0 1px;">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
                        <td valign="top" width="85%" height="100%" class="windowbg2">
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al";
//2007-02-18: midessa-forum-468x15
google_ad_channel = "8866871717";
google_color_border = "423935";
google_color_bg = "423935";
google_color_link = "D0D0D0";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
<td valign="top" width="85%" height="100%" class="windowbg">
<br />
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-468x60
google_ad_channel = "8764535480";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br><br/>
</div>
<br />
</td>
</tr>
</table>
</td>
</tr>';
}
// End Adsense after first post.


Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Muldoon on February 25, 2007, 11:34:45 PM
nite0859,

Thank you so much! As I have to head off to bed soon, I'll hopefully be able to tackle this tomorrow. woot! Can't wait to get started.

Muldoon
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on February 27, 2007, 11:26:08 PM
I also posted information about how to integrate Amazon searching into posts.
http://www.simplemachines.org/community/index.php?topic=154105.0

Demo : here.
Edit: 06-18-2007
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Roph on March 11, 2007, 05:39:58 PM
I'll just share something I've done - placed ads after the first post of a topic and only made them visible to guests.

in display.template.php,

// 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>';
//Ads

if ($message['id'] == $context['first_message'] && $context['user']['is_guest'])
{
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-7302574677795924";
google_alternate_color = "EEEEEE";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2006-12-12: RMRK
google_ad_channel = "8337678587";
google_color_border = "EEEEEE";
google_color_bg = "EEEEEE";
google_color_link = "7880A8";
google_color_text = "000000";
google_color_url = "7880A8";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br>Registered users do not see advertisements. Please consider <a href="http://rmrk.net/index.php?action=register;" title="Register">registering</a>!
</div>
</td></tr></table></td></tr>';
}
}



echo '

<tr><td style="padding: 0 0 1px 0;"></td></tr>

</table>

<a name="lastPost"></a>';

echo '
<tr><td style="padding: 0 0 1px 0;"></td></tr>
</table>
<a name="lastPost"></a>';

// As before, build the custom button right.


of course change the ad code and put in your own details :)

I also showed a small notice to guests mentioning that they don't see them if they sign up. It seems to work pretty well at getting more people to register :)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: HoTmetal on March 11, 2007, 10:30:02 PM
Great tips. Thanks for sharing.
Also there is an ad mod for SMF .

http://custom.simplemachines.org/mods/index.php?mod=255


Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: sniderz on March 14, 2007, 07:57:11 AM
This is a great code addition. I have added it to my forums over at www.sniderz.com and have pushed it to the right. My question is, is there anyway to make it as its own post? What I mean it you could create a user called Google that posts ads after the first post on all forums.

If this is not available could I ad a avatar to the left sie of this code to at least make it look like it was a poster?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Roph on March 14, 2007, 07:59:57 AM
I'm not sure if that'd go down too well with google's policies. They might see it as deceptive, trying to make it look like a user's post in order to get clicks. But either way, it shouldn't be that hard. I'll see what I can do.

Personally, I wouldn't try that on my own forum though.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: sniderz on March 14, 2007, 08:04:00 AM
Quote from: Silverline on March 14, 2007, 07:59:57 AM
I'm not sure if that'd go down too well with google's policies. They might see it as deceptive, trying to make it look like a user's post in order to get clicks. But either way, it shouldn't be that hard. I'll see what I can do.

Personally, I wouldn't try that on my own forum though.

I appreciate the help !!

Also phpbb, ip board and many others do it like that , that is why I am asking.

Thanks again for the help !!!

http://www.got-heroes.com/The-list-is-unfair-t1088.html is where I saw it last.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Harro on March 14, 2007, 10:17:33 AM
Great post.
Should deserve a sticky actually.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on March 14, 2007, 07:01:09 PM
Quote from: Harro on March 14, 2007, 10:17:33 AM
Great post.
Should deserve a sticky actually.

The Admin of webmaster's Talks (http://www.webmasterstalks.com) deserves 100% credit. I took his idea and modified it a little bit. Hopefully more people will take advantage of his knowledge and skill, since it does indeed exceed mine.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: usama07 on March 15, 2007, 12:10:03 PM
hey thnxs for that!!
I was really looking for that...
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: crud3w4re on March 15, 2007, 02:22:48 PM
Here's a better solution: Use the admod. ;)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: sniderz on March 15, 2007, 02:25:05 PM
I actually am using the ad mod and it works great for 1 set of ads. As in I can't use after the first post for both adsense and auctionads etc.  Its a great mod but should allow for more occurrences of different ad companies.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Harro on March 15, 2007, 02:31:55 PM
Quote from: crud3w4re on March 15, 2007, 02:22:48 PM
Here's a better solution: Use the admod. ;)
When doing it manually you never have to look at compatability isues, new versions,...
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Roph on March 16, 2007, 07:05:40 AM
I originally just wrote my own directly into my template because as an admin I couldn't stop myself seeing the ads, as I automatically have all privelages (so it includes being able to see the ads). I only want to show ads to guests. Though now I hear the ad mod can do that =o
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: sniderz on March 16, 2007, 07:08:21 AM
From what I have seen yes it can show only to guests. My ads are making me to much money now to take them away from members. I think once the community grows a bit more I will start taking them out.
Need to pay hosting fees :-)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on March 16, 2007, 01:22:59 PM
/me freaks that his post is a sticky.

Looks like I'm going to provide a little more detail for other positions as well. However, I do recommend that one looks at the code reference points found inside the installation XML for the ad mangement mod.

In a nut shell it boils down to this. When editing particular file, search for </table> .  Chances are, if you place adsense in another <table> right after </table> you'll be fine; this is how I am experimenting.

When doing a <table> you can use <td=align="center" valign="middle" class="windowbg"> in order to cut that table in half in order to display two adsense scripts side by side.

Example


<table>
<td align="center" valign="middle" class=windowbg">

Adsense CODE here.

</td>
<td align="center" valign="middle" class=windowbg">

Adsense CODE here too.

</td>
</table>



And if you really want to get funky ::


<table>
<td align="center" valign="middle" class=windowbg">
<div class="windowbg2">

Adsense CODE here.
</div>
</td>
<td align="center" valign="middle" class=windowbg">
<div class="windowbg2">

Adsense CODE here too.

</div>
</td>
</table>


Remember, also backup your original files BEFORE experimenting.

Putting adsense on top of a graphical banner for better design
Imagine putting a 160x600 adsense banner, that uses a white background (#FFFFFF) in side this graphic table to create a nice shade effect.
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fadclustr.com%2Fwp-content%2Fuploads%2F2007%2F01%2Fwhitewide.png&hash=82cb5da04c7762a206ae03012adbf0d3444d27a9)

Please, don't let this thread degenerate into a "You click on my ads and I'll click on yours" type thing. It's unethical, you'll get banned from Google, and you'll stir the anger from many other members on here. Be cool, be creative.

Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on March 17, 2007, 12:04:36 PM
Original post :: here.

In order to encourage Guests to register for an account on your forum, you can choose to display certain messages and advertisements to them. Registered members can see a different message or advertisement in the same location, or you can choose to omit the message or advertisement entirely for registered members.

Always make backups of your files before attempting any coding modification.

The file to be edited largely depends upon where you desire to have the advertisement and/or message shown.


The key here is to make a particular piece of coding "conditional". This means that the code is executed only after certain conditions are met.

Remember, I always put "more" code in so that you can find reference points. Also, do not simply cut and paste this code; this is custom code for my forum and it will not work on yours. You have to edit the URL of the image you desire to use, and the URL of your forum.

Quote
In the code below, my actual code begins where ::
// This message is shown to guests. This message will disappear upon registration.

index.template.php

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">
<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
</td>';
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />&nbsp;
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';

// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

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

// This message is shown to guests. This message will disappear upon registration.
if ($context['user']['is_guest'])
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<td width="65px" align="center" valign="middle" class="windowbg3">
<a href="http://forum.midessa.net/index.php?action=register"><img src="http://XXX.XXX.XXX/Themes/default/images/XXX.png" alt="Register to remove banner" title="Register an account to close this banner" />
</a>
</td>
<td valign="middle" class="windowbg3">
<font size="3" color="#D0D0D0"><b>You are browsing this forum as a guest. Please <a href="http://forum.midessa.net/index.php?action=register">register</a> for an account or <a href="http://forum.midessa.net/index.php?action=login">login</a> to remove this message.</b></font>
</td>
</table>';

// This message is shown to users with a low post count < 5. This message will disappear after 5 posts.
global $user_info;
if (($context['user']['is_logged']) && ($user_info['posts'] < 5 ))
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<td width="65px" align="center" valign="middle" class="windowbg3">
<a href="http://forum.midessa.net/introductions-b11.0/"><img src="http://XXXX.XXXX.XXX/Themes/default/images/XXX.gif" alt="Your post count is too low." title="Please contribute 5 messages to our community" />
</a>
</td>
<td valign="middle" class="windowbg3">
<font size="3" color="#E0E0FF"><b>Please contribute 5 thoughtful posts in order to remove this message.</b></font>
</td>
</table>';


The conditional statement that identifies guests is

The conditional statement used to identify registered members who have a low post count

In a similar vein, you can choose to display certain advertisements to guests while showing other, different, advertisements to members.

Quote
In the below example, my actual code begins where ::
// Guests will always see a 468x60 Graphical Banner right about the search form.

index.template.php

// display the time
echo '
<td class="titlebg2" height="32" align="right">
<span class="smalltext">' , $context['current_time'], '</span>';

// this is the upshrink button for the user info section
echo '
<a href="#" onclick="shrinkHeader(!current_header); return false;"><img id="upshrink" src="', $settings['images_url'], '/', empty($options['collapse_header']) ? 'upshrink.gif' : 'upshrink2.gif', '" alt="*" title="', $txt['upshrink_description'], '" align="bottom" style="margin: 0 1ex;" /></a>
</td>
</tr>
<tr id="upshrinkHeader"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>
<td valign="top" colspan="2">
<table width="100%" class="bordercolor" cellpadding="8" cellspacing="1" border="0" style="margin-top: 1px;">
<tr>';

if (!empty($context['user']['avatar']))
echo '
<td class="windowbg" valign="middle">', $context['user']['avatar']['image'], '</td>';

echo '
<td colspan="2" width="100%" valign="top" class="windowbg2"><span class="middletext">';

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
echo '
<a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a> <br />
<a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a><br />';



}
// Otherwise they're a guest - send them a lovely greeting...
else
echo $txt['welcome_guest'];

// Guests will always see a 468x60 Graphical Banner right above the search form.
if ($context['user']['is_guest'])
echo '
<td valign="middle" align="right" class="windowbg2">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "image";
//2007-03-17: midessa-forum-468x60
google_ad_channel = "8764535480";
google_color_border = "323935";
google_color_bg = "323935";
google_color_link = "FFFFCC";
google_color_text = "D0D0D0";
google_color_url = "FFFFFF";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>';

// However, registered members will see a 234x60 Text Banner above the search form.
else
echo '
<td valign="middle" align="right" class="windowbg2">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text";
//2007-03-15: midessa-forum-234x60
google_ad_channel = "9422463529";
google_color_border = "323935";
google_color_bg = "323935";
google_color_link = "99C9FF";
google_color_text = "D0D0D0";
google_color_url = "FFFFFF";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>';
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: qd-race on April 01, 2007, 01:25:11 AM
I want to manual mod to other theme. What files should I edit?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on April 01, 2007, 01:40:03 AM
Quote from: qd-race on April 01, 2007, 01:25:11 AM
I want to manual mod to other theme. What files should I edit?

Check out the very first post ...
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: mojito on April 01, 2007, 12:56:06 PM
The codes that are shown are significantly shorter than the original ones (unedited eg Display.template.php, so do we insert rather than replace the code in the grey box.And its not always clear where to insert the code in the grey box.

Is this mod for all versions ?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on April 01, 2007, 01:30:23 PM
Quote from: mojito on April 01, 2007, 12:56:06 PM
The codes that are shown are significantly shorter than the original ones (unedited eg Display.template.php, so do we insert rather than replace the code in the grey box.And its not always clear where to insert the code in the grey box.

Is this mod for all versions ?


Ok, I get what you're saying. The code inside the gray "code" box represent a small snippet of code that produces the over-all adsense placement. Referencing the entire code would not be a good idea because there are modifications out there that alter the code, and since not all people have all the same modifications installed, it would be a nightmare to tell people to use this one-and-only display.template.php, for example.

However, there are some common denominators inside these particular files. For example, regardless of your theme, and regardless of the modifications installed, there are some common snippets of code that must remain constant. As an example, I reference the "surrounding" code that serves as a cue to know what to look for inside the larger display.template.php.

In the first post, for example, when editing Display.template.php, you can search for

// 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>';


(Display.template.php) The point of the matter is to place the small adsense snippet of code after the

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


However, if you have a signature modification installed, this may appear different.

When putting adsense directly into your template, seek out where tables close by searching for </table>. When I experiment, I place adsense code after a table closure.

The particular adsense code would be ::

// Adsense after first post.
if ($message['id'] == $context['first_message'])
{
&nbsp; &nbsp; echo '
&nbsp; &nbsp; &nbsp; &nbsp; <tr>
<td style="padding: 0px 1px 0 1px;">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td valign="top" width="85%" height="100%" class="windowbg2">
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al";
//2007-02-18: midessa-forum-468x15
google_ad_channel = "8866871717";
google_color_border = "423935";
google_color_bg = "423935";
google_color_link = "D0D0D0";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
&nbsp; src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>
<td valign="top" width="85%" height="100%" class="windowbg">
<br />
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-468x60
google_ad_channel = "8764535480";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
&nbsp; src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br><br/>
</div>
<br />
</td>
</tr>
</table>
</td>
</tr>';
}
// End Adsense after first post.


However, I thought that it would be a good idea to pattern how adsense is displayed after how adsense is displayed on other popular forums, such as Digital Point (http://forums.digitalpoint.com/).

In this case, the adsense code would look like this ::

// Adsense after first post.
if ($message['id'] == $context['first_message'])
{
echo '
<tr>
<td style="padding: 0px 1px 0 1px;">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="middle" align="center" width="100%" class="windowbg2">
<script type="text/javascript"><!--
google_ad_client = "pub-1784233218325525";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728x15_0ads_al";
//2007-03-15: midessa-forum-728x15
google_ad_channel = "7377725223";
google_color_border = "323935";
google_color_bg = "323935";
google_color_link = "E9E9E9";
google_color_text = "D0D0D0";
google_color_url = "FFFFFF";
//-->
</script>
<script type="text/javascript"
&nbsp; src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
</table>

<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<td valign="middle" align="center" width="100%" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-1784233218325525";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
//2007-03-15: midessa-forum-728x90
google_ad_channel = "8891092745";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "E9E9E9";
google_color_text = "D0D0D0";
google_color_url = "F7E0AA";
//-->
</script>
<script type="text/javascript"
&nbsp; src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</table>

<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<td valign="middle" align="center" width="100%" class="windowbg2">
<script type="text/javascript"><!--
google_ad_client = "pub-1784233218325525";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
//2007-03-15: midessa-forum-728x90
google_ad_channel = "8891092745";
google_color_border = "323935";
google_color_bg = "323935";
google_color_link = "E9E9E9";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//-->
</script>
<script type="text/javascript"
&nbsp; src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

</td>
</table>
</td>
</tr>
';
}
// End Adsense after first post.


In anycase, I experiment with this quite often. If you find a post, any post, on my forum (http://www.midessa.net/forum), you'll see what that code looks like.

In essence, then, I don't list the totality of a particular file because such files are modified and diverse. My template wouldn't be the same as templates found on other sites. However, despite the diversity, there must be some common denominators, and the adsense-snippet is placed after such commonalities.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: dabblingdiva on April 11, 2007, 03:05:44 PM
This worked so great! Thanks for posting!!!!
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: rsmini on April 25, 2007, 11:10:52 AM
Just deciding which two templates to use. Millenium works very well to display adsense after the 1st post but my other template .. Neptune.. does not have the display.template.php file for some reason.

Please can you give me any advice how to get around this so adsense will display in Neptune as well
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Harro on April 25, 2007, 12:18:50 PM
Then you have to change Display.template.php from the default theme.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: rsmini on April 26, 2007, 12:19:42 AM
Quote from: Harro on April 25, 2007, 12:18:50 PM
Then you have to change Display.template.php from the default theme.

I thought it was that ... but I do like to check :) Thanks for your help I will try this later today as it does seem an easier way to get the adverts working
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: rsmini on April 27, 2007, 08:23:47 AM
To only change display.template in the default theme when using "neptune theme" does not seem to work. I asked the question the in the neptune theme thread and received this reply

QuoteWhenever some template seems to be mssing in a theme, its because it hasn't changed it for itself - so it falls back on default theme.

This mod require also index.template and BoardIndex.template to be changed it seems - you need to change those too in Neptune.

Would be most grateful if someone could be so kind as to supply the code for these changes as I really do not know where to start. I am after the adsense ads appearing after the 1st post in neptune. At the moment this does not seem to work.

It works perfect in default and "millenium" but most of my members are using neptune. The easy answer of course is to change the default theme to Millenium..
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: ronak on April 28, 2007, 12:57:33 AM
<?php
/**********************************************************************************
* index.php                                                                       *
***********************************************************************************
* SMF: Simple Machines Forum                                                      *
* Open-Source Project Inspired by Zef Hemel ([email protected])                    *
* =============================================================================== *
* Software Version:           SMF 1.1.2                                           *
* Software by:                Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006 by:          Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
* Support, News, Updates at:  http://www.simplemachines.org                       *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
**********************************************************************************/


/* This, as you have probably guessed, is the crux on which SMF functions.
Everything should start here, so all the setup and security is done
properly.  The most interesting part of this file is the action array in
the smf_main() function.  It is formatted as so:

'action-in-url' => array('Source-File.php', 'FunctionToCall'),

Then, you can access the FunctionToCall() function from Source-File.php
with the URL index.php?action=action-in-url.  Relatively simple, no?
*/

$forum_version 'SMF 1.1.2';

// Get everything started up...
define('SMF'1);
@
set_magic_quotes_runtime(0);
error_reporting(E_ALL);
$time_start microtime();

// Load the settings...
require_once(dirname(__FILE__) . '/Settings.php');

// And important includes.
require_once($sourcedir '/QueryString.php');
require_once(
$sourcedir '/Subs.php');
require_once(
$sourcedir '/Errors.php');
require_once(
$sourcedir '/Load.php');
require_once(
$sourcedir '/Security.php');

// Using an old version of PHP?
if (@version_compare(PHP_VERSION'4.2.3') != 1)
require_once($sourcedir '/Subs-Compat.php');

// If $maintenance is set specifically to 2, then we're upgrading or something.
if (!empty($maintenance) && $maintenance == 2)
db_fatal_error();

// Connect to the MySQL database.
if (empty($db_persist))
$db_connection = @mysql_connect($db_server$db_user$db_passwd);
else
$db_connection = @mysql_pconnect($db_server$db_user$db_passwd);

// Show an error if the connection couldn't be made.
if (!$db_connection || !@mysql_select_db($db_name$db_connection))
db_fatal_error();

// Load the settings from the settings table, and perform operations like optimizing.
reloadSettings();
// Clean the request variables, add slashes, etc.
cleanRequest();
$context = array();

// Determine if this is using WAP, WAP2, or imode.  Technically, we should check that wap comes before application/xhtml or text/html, but this doesn't work in practice as much as it should.
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/vnd.wap.xhtml+xml') !== false)
$_REQUEST['wap2'] = 1;
elseif (isset(
$_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false)
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'DoCoMo/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'portalmmm/') !== false)
$_REQUEST['imode'] = 1;
else
$_REQUEST['wap'] = 1;
}

if (!
defined('WIRELESS'))
define('WIRELESS', isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode']));

// Some settings and headers are different for wireless protocols.
if (WIRELESS)
{
define('WIRELESS_PROTOCOL', isset($_REQUEST['wap']) ? 'wap' : (isset($_REQUEST['wap2']) ? 'wap2' : (isset($_REQUEST['imode']) ? 'imode' '')));

// Some cellphones can't handle output compression...
$modSettings['enableCompressedOutput'] = '0';
// !!! Do we want these hard coded?
$modSettings['defaultMaxMessages'] = 5;
$modSettings['defaultMaxTopics'] = 9;

// Wireless protocol header.
if (WIRELESS_PROTOCOL == 'wap')
header('Content-Type: text/vnd.wap.wml');
}

// Check if compressed output is enabled, supported, and not already being done.
if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0)
{
// If zlib is being used, turn off output compression.
if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler' || @version_compare(PHP_VERSION'4.2.0') == -1)
$modSettings['enableCompressedOutput'] = '0';
else
ob_start('ob_gzhandler');
}
// This makes it so headers can be sent!
if (empty($modSettings['enableCompressedOutput']))
ob_start();

// Register an error handler.
set_error_handler('error_handler');

// Start the session. (assuming it hasn't already been.)
loadSession();

// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());

// Call obExit specially; we're coming from the main area ;).
obExit(nullnulltrue);

// The main controlling function.
function smf_main()
{
global $modSettings$settings$user_info$board$topic$maintenance$sourcedir;

// Special case: session keep-alive.
if (isset($_GET['action']) && $_GET['action'] == 'keepalive')
die;

// Load the user's cookie (or set as guest) and load their settings.
loadUserSettings();

// Load the current board's information.
loadBoard();

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
loadTheme();

// Check if the user should be disallowed access.
is_not_banned();

// Load the current user's permissions.
loadPermissions();

// Do some logging, unless this is an attachment, avatar, theme option or XML feed.
if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach''jsoption''.xml')))
{
// Log this user as online.
writeLog();

// Track forum statistics and hits...?
if (!empty($modSettings['hitStats']))
trackStats(array('hits' => '+'));
}

// Is the forum in maintenance mode? (doesn't apply to administrators.)
if (!empty($maintenance) && !allowedTo('admin_forum'))
{
// You can only login.... otherwise, you're getting the "maintenance mode" display.
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'login2')
{
require_once($sourcedir '/LogInOut.php');
return 'Login2';
}
// Don't even try it, sonny.
else
{
require_once($sourcedir '/Subs-Auth.php');
return 'InMaintenance';
}
}
// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('login''login2''register''register2''reminder''activate''smstats''help''.xml''verificationcode'))))
{
require_once($sourcedir '/Subs-Auth.php');
return 'KickGuest';
}
elseif (empty($_REQUEST['action']))
{
// Action and board are both empty... BoardIndex!
if (empty($board) && empty($topic))
{
require_once($sourcedir '/BoardIndex.php');
return 'BoardIndex';
}
// Topic is empty, and action is empty.... MessageIndex!
elseif (empty($topic))
{
require_once($sourcedir '/MessageIndex.php');
return 'MessageIndex';
}
// Board is not empty... topic is not empty... action is empty.. Display!
else
{
require_once($sourcedir '/Display.php');
return 'Display';
}
}

// Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
$actionArray = array(
'activate' => array('Register.php''Activate'),
'admin' => array('Admin.php''Admin'),
'announce' => array('Post.php''AnnounceTopic'),
'ban' => array('ManageBans.php''Ban'),
'boardrecount' => array('Admin.php''AdminBoardRecount'),
'buddy' => array('Subs-Members.php''BuddyListToggle'),
'calendar' => array('Calendar.php''CalendarMain'),
'cleanperms' => array('Admin.php''CleanupPermissions'),
'collapse' => array('Subs-Boards.php''CollapseCategory'),
'convertentities' => array('Admin.php''ConvertEntities'),
'convertutf8' => array('Admin.php''ConvertUtf8'),
'coppa' => array('Register.php''CoppaForm'),
'deletemsg' => array('RemoveTopic.php''DeleteMessage'),
'detailedversion' => array('Admin.php''VersionDetail'),
'display' => array('Display.php''Display'),
'dlattach' => array('Display.php''Download'),
'dumpdb' => array('DumpDatabase.php''DumpDatabase2'),
'editpoll' => array('Poll.php''EditPoll'),
'editpoll2' => array('Poll.php''EditPoll2'),
'featuresettings' => array('ModSettings.php''ModifyFeatureSettings'),
'featuresettings2' => array('ModSettings.php''ModifyFeatureSettings2'),
'findmember' => array('Subs-Auth.php''JSMembers'),
'help' => array('Help.php''ShowHelp'),
'helpadmin' => array('Help.php''ShowAdminHelp'),
'im' => array('PersonalMessage.php''MessageMain'),
'jsoption' => array('Themes.php''SetJavaScript'),
'jsmodify' => array('Post.php''JavaScriptModify'),
'lock' => array('LockTopic.php''LockTopic'),
'lockVoting' => array('Poll.php''LockVoting'),
'login' => array('LogInOut.php''Login'),
'login2' => array('LogInOut.php''Login2'),
'logout' => array('LogInOut.php''Logout'),
'maintain' => array('Admin.php''Maintenance'),
'manageattachments' => array('ManageAttachments.php''ManageAttachments'),
'manageboards' => array('ManageBoards.php''ManageBoards'),
'managecalendar' => array('ManageCalendar.php''ManageCalendar'),
'managesearch' => array('ManageSearch.php''ManageSearch'),
'markasread' => array('Subs-Boards.php''MarkRead'),
'membergroups' => array('ManageMembergroups.php''ModifyMembergroups'),
'mergetopics' => array('SplitTopics.php''MergeTopics'),
'mlist' => array('Memberlist.php''Memberlist'),
'modifycat' => array('ManageBoards.php''ModifyCat'),
'modifykarma' => array('Karma.php''ModifyKarma'),
'modlog' => array('Modlog.php''ViewModlog'),
'movetopic' => array('MoveTopic.php''MoveTopic'),
'movetopic2' => array('MoveTopic.php''MoveTopic2'),
'news' => array('ManageNews.php''ManageNews'),
'notify' => array('Notify.php''Notify'),
'notifyboard' => array('Notify.php''BoardNotify'),
'optimizetables' => array('Admin.php''OptimizeTables'),
'packageget' => array('PackageGet.php''PackageGet'),
'packages' => array('Packages.php''Packages'),
'permissions' => array('ManagePermissions.php''ModifyPermissions'),
'pgdownload' => array('PackageGet.php''PackageGet'),
'pm' => array('PersonalMessage.php''MessageMain'),
'post' => array('Post.php''Post'),
'post2' => array('Post.php''Post2'),
'postsettings' => array('ManagePosts.php''ManagePostSettings'),
'printpage' => array('Printpage.php''PrintTopic'),
'profile' => array('Profile.php''ModifyProfile'),
'profile2' => array('Profile.php''ModifyProfile2'),
'quotefast' => array('Post.php''QuoteFast'),
'quickmod' => array('Subs-Boards.php''QuickModeration'),
'quickmod2' => array('Subs-Boards.php''QuickModeration2'),
'recent' => array('Recent.php''RecentPosts'),
'regcenter' => array('ManageRegistration.php''RegCenter'),
'register' => array('Register.php''Register'),
'register2' => array('Register.php''Register2'),
'reminder' => array('Reminder.php''RemindMe'),
'removetopic2' => array('RemoveTopic.php''RemoveTopic2'),
'removeoldtopics2' => array('RemoveTopic.php''RemoveOldTopics2'),
'removepoll' => array('Poll.php''RemovePoll'),
'repairboards' => array('RepairBoards.php''RepairBoards'),
'reporttm' => array('SendTopic.php''ReportToModerator'),
'reports' => array('Reports.php''ReportsMain'),
'requestmembers' => array('Subs-Auth.php''RequestMembers'),
'search' => array('Search.php''PlushSearch1'),
'search2' => array('Search.php''PlushSearch2'),
'sendtopic' => array('SendTopic.php''SendTopic'),
'serversettings' => array('ManageServer.php''ModifySettings'),
'serversettings2' => array('ManageServer.php''ModifySettings2'),
'smileys' => array('ManageSmileys.php''ManageSmileys'),
'smstats' => array('Stats.php''SMStats'),
'spellcheck' => array('Subs-Post.php''SpellCheck'),
'splittopics' => array('SplitTopics.php''SplitTopics'),
'stats' => array('Stats.php''DisplayStats'),
'sticky' => array('LockTopic.php''Sticky'),
'theme' => array('Themes.php''ThemesMain'),
'trackip' => array('Profile.php''trackIP'),
'about:mozilla' => array('Karma.php''BookOfUnknown'),
'about:unknown' => array('Karma.php''BookOfUnknown'),
'unread' => array('Recent.php''UnreadTopics'),
'unreadreplies' => array('Recent.php''UnreadTopics'),
'viewErrorLog' => array('ManageErrors.php''ViewErrorLog'),
'viewmembers' => array('ManageMembers.php''ViewMembers'),
'viewprofile' => array('Profile.php''ModifyProfile'),
'verificationcode' => array('Register.php''VerificationCode'),
'vote' => array('Poll.php''Vote'),
'viewquery' => array('ViewQuery.php''ViewQuery'),
'who' => array('Who.php''Who'),
'.xml' => array('News.php''ShowXmlFeed'),
);

// Get the function and file to include - if it's not there, do the board index.
if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']]))
{
// Catch the action with the theme?
if (!empty($settings['catch_action']))
{
require_once($sourcedir '/Themes.php');
return 'WrapAction';
}

// Fall through to the board index then...
require_once($sourcedir '/BoardIndex.php');
return 'BoardIndex';
}

// Otherwise, it was set - so let's go to that action.
require_once($sourcedir '/' $actionArray[$_REQUEST['action']][0]);
return $actionArray[$_REQUEST['action']][1];
}

?>


...........................................

This is My Index.php

what should i edit in this can anyone here tell me need to add banner Onthe Home page like

this site and even like

http://www.cricketvoice.com

he has added banner on the main page

i want to add 2 times on the index page and after the first post also can anyone send here the edited file

thanks
Ronak

Mod edit: Code tags
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Harro on April 28, 2007, 05:56:33 AM
First of all it's index.template.php in your Themes folder, and not index.php
And for after the first post it's display.template.php
Read the first posts for how exactly you have to do it.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Roph on June 07, 2007, 12:54:48 PM
Long time no see to all of you in this thread :P

I wrote up about a simple modificaiton I made to the way I display ads on my forum. Basically, logged in members are able to hide the ads for a configurable amount of time. It's a fairly long post, so I'll just link it instead:

http://slyph.org/blog/2007/06/07/smf-show-ads-to-guests-members-though-let-members-hide-them/

I hope this is of help to people :)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: ham1299 on June 15, 2007, 11:38:05 PM
Thanks so much! It helped tremendously! :D
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on June 18, 2007, 07:16:10 PM
Quote from: ham1299 on June 15, 2007, 11:38:05 PM
Thanks so much! It helped tremendously! :D

Always pleased to help.

On a side note, I'm re-installing my forum, so I haven't had a chance to implement new stuff yet. Will edit first post.. 06-18-2007
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: dripac on August 27, 2007, 10:02:56 PM
Thanks allot for the helpful info.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: rock lee wit tits on September 07, 2007, 10:36:12 PM
all i need to know is how to make one
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on September 08, 2007, 02:41:06 PM
Quote from: rock lee wit tits on September 07, 2007, 10:36:12 PM
all i need to know is how to make one

Make one of what? A Google ad? A template revision?

You need to apply to the adsense program @ http://www.google.com/adsense ... then, you can create and customize and ad... Google will give you that code, and per G's TOS, you cannot jack around with that code.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: cru on September 15, 2007, 08:21:57 AM
hi, i tried the part :
QuoteDisplay.template.php -- Puts adsense after EVERY first post.

in this thread's first post. but i have 2 questions.

1. i would like it to look like this, but i don't know how
http://www.sulit.com.ph/forum/viewtopic.php?t=2669&start=0

i can't seem to find the background color to blend with the default theme, coz i think its not possible to tweak a google ad that would show NO BACKGROUND.

2. i can't align it like the one shown in the link, i like the way the banner is aligned. Can u please teach me how to let it float like 100pixels to the right?

TIA!
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Niteblade on September 16, 2007, 11:09:56 AM
Quote from: cru on September 15, 2007, 08:21:57 AM
hi, i tried the part :
QuoteDisplay.template.php -- Puts adsense after EVERY first post.

in this thread's first post. but i have 2 questions.

1. i would like it to look like this, but i don't know how
http://www.sulit.com.ph/forum/viewtopic.php?t=2669&start=0

i can't seem to find the background color to blend with the default theme, coz i think its not possible to tweak a google ad that would show NO BACKGROUND.

2. i can't align it like the one shown in the link, i like the way the banner is aligned. Can u please teach me how to let it float like 100pixels to the right?

TIA!

Some forums use an image (gradient effects) for their background. Google does not allow images to be used as backgrounds. Regarding that link you provided, did you scan thru the source of the page for the .css style?


/*
  The original subSilver Theme for phpBB version 2+
  Created by subBlue design
  http://www.subBlue.com
*/
/* General page style. The scroll bar colours only visible in IE5.5+ */
body {
background-color: #E5E5E5;
scrollbar-face-color: #DEE3E7;
scrollbar-highlight-color: #FFFFFF;
scrollbar-shadow-color: #DEE3E7;
scrollbar-3dlight-color: #D1D7DC;
scrollbar-arrow-color: #006699;
scrollbar-track-color: #EFEFEF;
scrollbar-darkshadow-color: #98AAB1;
}

/* General font families for common tags */
font,th,td,p {
font-family: Verdana, Arial, Helvetica, sans-serif
}

a:link,a:active,a:visited {
color: #006699;
}

a:hover {
text-decoration: underline;
color: #DD6900;
}

hr {
height: 0px;
border: solid #D1D7DC 0px;
border-top-width: 1px;
}

/* This is the border line & background colour round the entire page */
.bodyline {
background-color: #FFFFFF;
border: 1px #98AAB1 solid;
}

/* This is the outline round the main forum tables */
.forumline {
background-color: #FFFFFF;
border: 2px #006699 solid;
}

/* Main table cell colours and backgrounds */
td.row1 {
background-color: #EFEFEF;
}

td.row2 {
background-color: #DEE3E7;
}

td.row3 {
background-color: #D1D7DC;
}

/*
  This is for the table cell above the Topics, Post & Last posts on the index.php page
  By default this is the fading out gradiated silver background.
  However, you could replace this with a bitmap specific for each forum
*/
td.rowpic {
background-color: #FFFFFF;
background-image: url(images/cellpic2.jpg);
background-repeat: repeat-y;
}

/* Header cells - the blue and silver gradient backgrounds */
th {
color: #FFA34F;
font-size: 11px;
font-weight: bold;
background-color: #006699;
height: 25px;
background-image: url(images/cellpic3.gif);
}

td.cat,td.catHead,td.catSides,td.catLeft,td.catRight,td.catBottom {
background-image: url(images/cellpic1.gif);
background-color: #D1D7DC;
border: #FFFFFF;
border-style: solid;
height: 28px;
}

/*
  Setting additional nice inner borders for the main table cells.
  The names indicate which sides the border will be on.
  Don't worry if you don't understand this, just ignore it :-)
*/
td.cat,td.catHead,td.catBottom {
height: 29px;
border-width: 0px 0px 0px 0px;
}

th.thHead,th.thSides,th.thTop,th.thLeft,th.thRight,th.thBottom,th.thCornerL,th.thCornerR
{
font-weight: bold;
border: #FFFFFF;
border-style: solid;
height: 28px;
}

td.row3Right,td.spaceRow {
background-color: #D1D7DC;
border: #FFFFFF;
border-style: solid;
}

th.thHead,td.catHead {
font-size: 12px;
border-width: 1px 1px 0px 1px;
}

th.thSides,td.catSides,td.spaceRow {
border-width: 0px 1px 0px 1px;
}

th.thRight,td.catRight,td.row3Right {
border-width: 0px 1px 0px 0px;
}

th.thLeft,td.catLeft {
border-width: 0px 0px 0px 1px;
}

th.thBottom,td.catBottom {
border-width: 0px 1px 1px 1px;
}

th.thTop {
border-width: 1px 0px 0px 0px;
}

th.thCornerL {
border-width: 1px 0px 0px 1px;
}

th.thCornerR {
border-width: 1px 1px 0px 0px;
}

/* The largest text used in the index page title and toptic title etc. */
.maintitle,h1,h2 {
font-weight: bold;
font-size: 22px;
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
text-decoration: none;
line-height: 120%;
color: #000000;
}

/* General text */
.gen {
font-size: 12px;
}

.genmed {
font-size: 11px;
}

.gensmall {
font-size: 10px;
}

.gen,.genmed,.gensmall {
color: #000000;
}

a.gen,a.genmed,a.gensmall {
color: #006699;
text-decoration: none;
}

a.gen:hover,a.genmed:hover,a.gensmall:hover {
color: #DD6900;
text-decoration: underline;
}

/* The register, login, search etc links at the top of the page */
.mainmenu {
font-size: 11px;
color: #000000
}

a.mainmenu {
text-decoration: none;
color: #006699;
}

a.mainmenu:hover {
text-decoration: underline;
color: #DD6900;
}

/* Forum category titles */
.cattitle {
font-weight: bold;
font-size: 12px;
letter-spacing: 1px;
color: #006699
}

a.cattitle {
text-decoration: none;
color: #006699;
}

a.cattitle:hover {
text-decoration: underline;
}

/* Forum title: Text and link to the forums used in: index.php */
.forumlink {
font-weight: bold;
font-size: 12px;
color: #006699;
}

a.forumlink {
text-decoration: none;
color: #006699;
}

a.forumlink:hover {
text-decoration: underline;
color: #DD6900;
}

/* Used for the navigation text, (Page 1,2,3 etc) and the navigation bar when in a forum */
.nav {
font-weight: bold;
font-size: 11px;
color: #000000;
}

a.nav {
text-decoration: none;
color: #006699;
}

a.nav:hover {
text-decoration: underline;
}

/* titles for the topics: could specify viewed link colour too */
.topictitle {
font-weight: bold;
font-size: 11px;
color: #000000;
}

a.topictitle:link {
text-decoration: none;
color: #006699;
}

a.topictitle:visited {
text-decoration: none;
color: #5493B4;
}

a.topictitle:hover {
text-decoration: underline;
color: #DD6900;
}

/* Name of poster in viewmsg.php and viewtopic.php and other places */
.name {
font-size: 11px;
color: #000000;
}

/* Location, number of posts, post date etc */
.postdetails {
font-size: 10px;
color: #000000;
}

/* The content of the posts (body of text) */
.postbody {
font-size: 12px;
}

a.postlink:link {
text-decoration: none;
color: #006699
}

a.postlink:visited {
text-decoration: none;
color: #5493B4;
}

a.postlink:hover {
text-decoration: underline;
color: #DD6900
}

/* Quote & Code blocks */
.code {
font-family: Courier, 'Courier New', sans-serif;
font-size: 11px;
color: #006600;
background-color: #FAFAFA;
border: #D1D7DC;
border-style: solid;
border-left-width: 1px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px
}

.quote {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #444444;
line-height: 125%;
background-color: #FAFAFA;
border: #D1D7DC;
border-style: solid;
border-left-width: 1px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px
}

/* Copyright and bottom info */
.copyright {
font-size: 10px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #444444;
letter-spacing: -1px;
}

a.copyright {
color: #444444;
text-decoration: none;
}

a.copyright:hover {
color: #000000;
text-decoration: underline;
}

/* Form elements */
input,textarea,select {
color: #000000;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
border-color: #000000;
}

/* The text input fields background colour */
input.post,textarea.post,select {
background-color: #FFFFFF;
}

input {
text-indent: 2px;
}

/* The buttons used for bbCode styling in message post */
input.button {
background-color: #EFEFEF;
color: #000000;
font-size: 11px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

/* The main submit button option */
input.mainoption {
background-color: #FAFAFA;
font-weight: bold;
}

/* None-bold submit button */
input.liteoption {
background-color: #FAFAFA;
font-weight: normal;
}

/* This is the line in the posting page which shows the rollover
  help line. This is actually a text box, but if set to be the same
  colour as the background no one will know ;)
*/
.helpline {
background-color: #DEE3E7;
border-style: none;
}

/* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */
@import url("formIE.css");


Now, whenever you see a "background-color" in there, copy that over to adsense body background box... experiment with the colors outlined in the .css file in order to get advertisements that better blend in with your theme, if that's what you want.

In this case, their 728x90 banner uses this :
Quote
google_color_border = "F1F1F1";
google_color_bg = "F1F1F1";
google_color_link = "025b97";
google_color_text = "000000";
google_color_url = "000000";

Regarding banner alignment:

Surround your adsense code with
<div align="center"> ADSENSE CODE </div>.

If you want your ads to float, then use
<div style="float: left; padding-top: 5px; padding-bottom: 5px; padding-right:5px;"> ADSENSE CODE</div>

Hope that helps.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: SlyBaldGuy on October 26, 2007, 02:57:28 PM
After several experiments, I've found that the best way to control my ad delivery in my forum and across the rest of my site is to do the following:

Setup the Ad Mod in SMF
Setup OpenADS (http://www.openads.org/) on my hosting server.
Setup different zones in OpenAds for the different pages of my site AND for different areas on my form.  (ex. Top Forum, In Post, Bottom Forum, etc)
I can then paste the code for each zone in the respective Ad Mod fields for each area of the forum.

I know this sounds like overkill, but it really allows me to control the way ads are played out on the site and to experiment with various ad networks other than Adsense.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: H on November 01, 2007, 03:28:00 PM
I moved this helpful topic to Tips and Tricks. Hopefully it will stop people asking for support in "Building your community and Other Forum Advice" while remaining useful :)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: _Dale_ on December 08, 2007, 05:52:30 PM
I was wondering if you could help me clear up an issue I'm having when editing the BoardIndex.template.php
It's returning
QuoteThe file you tried to save generated the following error:
Parse error: syntax error, unexpected $end in BoardIndex.template.php on line 318

Thanks a lot,

Dale.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Deaks on December 15, 2007, 02:38:34 PM
do you still require help with this?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: _Dale_ on December 15, 2007, 02:47:44 PM
Hi RunicWarrior,

If you're able to help me with this then that would be brill. I'm still getting the same error whilst editing the template.

Thanks,
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Deaks on December 16, 2007, 06:45:46 PM
can you post your boardindex.template.php specially 10 lines around the error line
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: _Dale_ on December 16, 2007, 07:11:56 PM
Thanks for the reply.

Here is the whole template (as it doesn't state the line numbers when editing)
function template_main()
{
   global $context, $settings, $options, $txt, $scripturl, $modSettings;
   
   // Show some statistics next to the link tree if SP1 info is off.
   echo '
   <table width="100%" cellpadding="0" cellspacing="0">
      <tr>
         <td valign="bottom">', theme_linktree(), '</td>
         <td align="right">';
   if (!$settings['show_sp1_info'])
      echo '
            ', $txt[19], ': ', $context['common_stats']['total_members'], ' &nbsp;&#8226;&nbsp; ', $txt[95], ': ', $context['common_stats']['total_posts'], ' &nbsp;&#8226;&nbsp; ', $txt[64], ': ', $context['common_stats']['total_topics'], '
            ', ($settings['show_latest_member'] ? '<br />' . $txt[201] . ' <b>' . $context['common_stats']['latest_member']['link'] . '</b>' . $txt[581] : '');
   echo '
         </td>
      </tr>
   </table>';

   // Show the news fader?  (assuming there are things to show...)
   if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
   {
      echo '
   <table border="0" width="100%" class="tborder" cellspacing="' , ($context['browser']['is_ie'] || $context['browser']['is_opera6']) ? '1' : '0' , '" cellpadding="4" style="margin-bottom: 2ex;">
      <tr>
         <td valign="middle" align="center" height="60" class="windowbg2">';

      // Prepare all the javascript settings.
      echo '
            <div id="smfFadeScroller" style="width: 90%; padding: 2px;"><b>', $context['news_lines'][0], '</b></div>
            <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
               // The fading delay (in ms.)
               var smfFadeDelay = ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], ';
               // Fade from... what text color? To which background color?
               var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 255, "g": 255, "b": 255};
               // Surround each item with... anything special?
               var smfFadeBefore = "<b>", smfFadeAfter = "</b>";

               var foreColor, backEl, backColor;

               if (typeof(document.getElementById(\'smfFadeScroller\').currentStyle) != "undefined")
               {
                  foreColor = document.getElementById(\'smfFadeScroller\').currentStyle.color.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
                  smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

                  backEl = document.getElementById(\'smfFadeScroller\');
                  while (backEl.currentStyle.backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined")
                     backEl = backEl.parentNode;

                  backColor = backEl.currentStyle.backgroundColor.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
                  smfFadeTo = {"r": eval("0x" + backColor[1]), "g": eval("0x" + backColor[2]), "b": eval("0x" + backColor[3])};
               }
               else if (typeof(window.opera) == "undefined" && typeof(document.defaultView) != "undefined")
               {
                  foreColor = document.defaultView.getComputedStyle(document.getElementById(\'smfFadeScroller\'), null).color.match(/rgb\((\d+), (\d+), (\d+)\)/);
                  smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

                  backEl = document.getElementById(\'smfFadeScroller\');
                  while (document.defaultView.getComputedStyle(backEl, null).backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
                     backEl = backEl.parentNode;

                  backColor = document.defaultView.getComputedStyle(backEl, null).backgroundColor.match(/rgb\((\d+), (\d+), (\d+)\)/);
                  smfFadeTo = {"r": parseInt(backColor[1]), "g": parseInt(backColor[2]), "b": parseInt(backColor[3])};
               }

               // List all the lines of the news for display.
               var smfFadeContent = new Array(
                  "', implode('",
                  "', $context['fader_news_lines']), '"
               );
            // ]]></script>
            <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/fader.js"></script>
         </td>
      </tr>
   </table>';
   }

   /* Each category in categories is made up of:
   id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
   new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down iamge),
   and boards. (see below.) */
   $first = true;
   foreach ($context['categories'] as $category)
   {
      echo '
   <div class="tborder" style="margin-top: ' , $first ? '0;' : '1ex;' , '' , $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'width: 100%;' : '', '">
      <div class="catbg', $category['new'] ? '2' : '', '" style="padding: 5px 5px 5px 10px;">';
      $first = false;

      // If this category even can collapse, show a link to collapse it.
      if ($category['can_collapse'])
         echo '
            <span style="float:right; margin-right:15px;"><a href="', $category['collapse_href'], '"><img src="', $settings['images_url'] . '/'. $settings['theme_main_color'], '/', !$category['is_collapsed'] ? 'collapse.gif' : 'expand.gif', '" alt="*" /></a></span>';

      echo '
            <span style="margin-left:80px;">', $category['link'], '</span>
      </div>';
     

     

      // Assuming the category hasn't been collapsed...
      if (!$category['is_collapsed'])
      {
         echo '
      <table border="0" width="100%" cellspacing="1" cellpadding="5" class="bordercolor" style="margin-top: 0px;">
         
         ',
         empty($settings['boardname_posts_lastposts_nodisplay']) ? '<tr>
            <td class="titlebg3" width="51" align="center" valign="middle">

            </td>
            <td class="titlebg3">
               '. $txt[20].'
            </td>
            <td class="titlebg3" valign="middle" align="center" style="width: 12ex;">
               '. $txt[21].'
            </td>
            <td class="titlebg3" valign="middle" align="center" width="22%">
               '. $txt[22].'
            </td>
         </tr>' : ''   ;
         
         /* Each board in each category's boards has:
         new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
         children (see below.), link_children (easier to use.), children_new (are they new?),
         topics (# of), posts (# of), link, href, and last_post. (see below.) */
         foreach ($category['boards'] as $board)
         {
            echo '
         <tr>
            <td class="windowbg" width="51" align="center" valign="middle"><a href="', $scripturl, '?action=unread;board=', $board['id'], '.0">';

            // If the board is new, show a strong indicator.
            if ($board['new'])
               echo '<img src="', $settings['images_url'] . '/'. $settings['theme_main_color'], '/on.gif" alt="', $txt[333], '" title="', $txt[333], '" />';
            // This board doesn't have new posts, but its children do.
            elseif ($board['children_new'])
               echo '<img src="', $settings['images_url'] . '/'. $settings['theme_main_color'], '/on2.gif" alt="', $txt[333], '" title="', $txt[333], '" />';
            // No new posts at all! The agony!!
            else
               echo '<img src="', $settings['images_url'] . '/'. $settings['theme_main_color'], '/off.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '</a>
            </td>
            <td class="windowbg2" style="padding-top:12px; padding-bottom:12px;">
               <b><a href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a></b><br />
                  ', $board['description'];

            // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
            if (!empty($board['moderators']))
               echo '
               <div style="padding-top: 1px;" class="smalltext"><br/><i>', count($board['moderators']) == 1 ? $txt[298] : $txt[299], ': ', implode(', ', $board['link_moderators']), '</i></div>';
           
            // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
            if (!empty($board['children']))
            {
               // Sort the links into an array with new boards bold so it can be imploded.
               $children = array();
               /* Each child in each board's children has:
                     id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
               foreach ($board['children'] as $child)
               {
                     $child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')">' . $child['name'] . '</a>';
                     $children[] = $child['new'] ? '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/onk.gif" alt="' . $txt[333] . '"/><b>' . $child['link'] . '</b>' : '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/offk.gif" alt="' . $txt[334] . '"/>' . $child['link'];                     
               }

               echo '
               <table style="float:right; margin-top: 15px;" width="100%" cellspacing="0" cellpadding="3" border="0">
                  <tr>
                     <td class="middletext" valign="middle" align="center" width="30%">
                        <b>', $txt['parent_boards'], ':</b>
                     ';

               $child_counter = 0;
               
               if(empty($settings['child_boards_rows']))
               {
                  echo '   
                     </td>
                     <td class="middletext" valign="top">';
                       
                        for(; $child_counter < ceil(count($children)/2); $child_counter++)
                              echo $children[$child_counter], '<br/>';
               }
               
               echo '
                     </td>
                     <td class="middletext" valign="top">';   
                        for(; $child_counter < count($children); $child_counter++)
                              echo $children[$child_counter], '<br/>';
               echo '
                     </td>
                  </tr>
               </table>';
            }
            // Show some basic information about the number of posts, etc.
               echo '
            </td>
            <td class="windowbg" valign="middle" align="center" style="width: 12ex;"><span class="smalltext">
               ', $board['posts'], ' ', $txt[21], ' <br />
               ', $board['topics'],' ', $txt[330], '
            </span></td>
            <td class="windowbg2" valign="middle" width="22%">
               <span class="smalltext">';

            /* The board's and children's 'last_post's have:
            time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
            link, href, subject, start (where they should go for the first unread post.),
            and member. (which has id, name, link, href, username in it.) */
            if (!empty($board['last_post']['id']))
               echo '
                  <b>', $txt[22], '</b>  ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
                  ', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
                  ', $txt[30], ' ', $board['last_post']['time'];
            echo '
               </span>
            </td>
         </tr>';
         }
         echo '
      </table>';
      }
      echo '
   </div>';
   }

   if ($context['user']['is_logged'])
   {
      echo '
   <table border="0" width="100%" cellspacing="0" cellpadding="5">
      <tr>
         <td align="', !$context['right_to_left'] ? 'left' : 'right', '" class="smalltext">
            <img src="' . $settings['images_url'] . '/'. $settings['theme_main_color'] . '/new_some.gif" alt="" align="middle" /> ', $txt[333], '
            <img src="' . $settings['images_url'] . '/'. $settings['theme_main_color'] . '/new_none.gif" alt="" align="middle" style="margin-left: 4ex;" /> ', $txt[334], '
         </td>
         <td align="', !$context['right_to_left'] ? 'right' : 'left', '">';

      // Mark read button.
      $mark_read_button = array('markread' => array('text' => 452, 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=all;sesc=' . $context['session_id']));

      // Show the mark all as read button?
      if ($settings['show_mark_read'] && !empty($context['categories']))
            echo '
            <table cellpadding="0" cellspacing="0" border="0" style="position: relative; top: -5px;">
               <tr>
                     ', template_button_strip($mark_read_button, 'top'), '
               </tr>
            </table>';
      echo '
         </td>
      </tr>
   </table>';
   }
   
// Adsense before info center.
    echo '
            <table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
                        <td valign="top" width="85%" height="100%" class="windowbg2">
                        <div style="overflow: auto; width: 100%;" align="center" class="windowbg">
                           <script type="text/javascript"><!--
                           google_ad_client = "pub-";
                           google_ad_width = 468;
                           google_ad_height = 15;
                           google_ad_format = "468x15_0ads_al";
                           //2007-02-18: midessa-forum-468x15
                           google_ad_channel = "8866871717";
                           google_color_border = "423935";
                           google_color_bg = "423935";
                           google_color_link = "D0D0D0";
                           google_color_text = "000000";
                           google_color_url = "008000";
                           //--></script>
                           <script type="text/javascript"
                             src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                           </script>
                        </div>
                  </td>
               </tr>
            </table>
            <table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
                  <td valign="top" width="85%" height="100%" class="windowbg">
                     <br />
                        <div style="overflow: auto; width: 100%;" align="center" class="windowbg">
                        <br />
<script type="text/javascript"><!--
google_ad_client = "pub-6062352907543865";
//468x60, created 16/12/07
google_ad_slot = "9713665407";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
                        <br><br />
                        </div>
                     <br />
                  </td>
               </tr>
         </table>';
// End Adsense before info center.

   // Here's where the "Info Center" starts...
   echo '<br />
   <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
      <div class="catbg" style="padding: 6px; vertical-align: middle; text-align: center; ">
         <a href="#" onclick="shrinkHeaderIC(!current_header_ic); return false;"><img id="upshrink_ic" src="', $settings['images_url'], '/', empty($options['collapse_header_ic']) ? 'collapse.gif' : 'expand.gif', '" alt="*" title="', $txt['upshrink_description'], '" style="margin-right: 2ex;" align="right" /></a>
         ', $txt[685], '
      </div>
      <div id="upshrinkHeaderIC"', empty($options['collapse_header_ic']) ? '' : ' style="display: none;"', '>
         <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';


That is the template I'm trying to save when receiving the error. The above contains the relative AdSense code also.

Thanks,
Dale.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Sarge on December 16, 2007, 07:22:08 PM
_Dale_, what theme (and theme version) are you using?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: _Dale_ on December 17, 2007, 08:23:33 AM
Hi Sarge, thanks for the reply.

The theme currently being used is the DilberMc one.

I understand that using a custom theme can cause problems. Is there any way around this at all?

Thanks,
Dale.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Fiery on January 11, 2008, 01:02:38 AM
If you want the ads before the info center, for boardindex.template.php try:

<?php
// Version: 1.1; BoardIndex

function template_main()
{
global $context$settings$options$txt$scripturl$modSettings;

// Show some statistics next to the link tree if SP1 info is off.
echo '
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom">'
theme_linktree(), '</td>
<td align="right">'
;
if (!$settings['show_sp1_info'])
echo '
'
$txt[19], ': '$context['common_stats']['total_members'], ' &nbsp;&#38;#8226;&nbsp; '$txt[95], ': '$context['common_stats']['total_posts'], ' &nbsp;&#38;#8226;&nbsp; '$txt[64], ': '$context['common_stats']['total_topics'], '
'
, ($settings['show_latest_member'] ? '<br />' $txt[201] . ' <b>' $context['common_stats']['latest_member']['link'] . '</b>' $txt[581] : '');
echo '
</td>
</tr>
</table>'
;

// Show the news fader?  (assuming there are things to show...)
if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
{
echo '
<table border="0" width="100%" class="tborder" cellspacing="' 
, ($context['browser']['is_ie'] || $context['browser']['is_opera6']) ? '1' '0' '" cellpadding="4" style="margin-bottom: 2ex;">
<tr>
<td valign="middle" align="center" height="60" class="windowbg2">'
;

// Prepare all the javascript settings.
echo '
<div id="smfFadeScroller" style="width: 90%; padding: 2px;"><b>'
$context['news_lines'][0], '</b></div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
// The fading delay (in ms.)
var smfFadeDelay = '
, empty($settings['newsfader_time']) ? 5000 $settings['newsfader_time'], ';
// Fade from... what text color? To which background color?
var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 255, "g": 255, "b": 255};
// Surround each item with... anything special?
var smfFadeBefore = "<b>", smfFadeAfter = "</b>";

var foreColor, backEl, backColor;

if (typeof(document.getElementById(\'smfFadeScroller\').currentStyle) != "undefined")
{
foreColor = document.getElementById(\'smfFadeScroller\').currentStyle.color.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

backEl = document.getElementById(\'smfFadeScroller\');
while (backEl.currentStyle.backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined")
backEl = backEl.parentNode;

backColor = backEl.currentStyle.backgroundColor.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
smfFadeTo = {"r": eval("0x" + backColor[1]), "g": eval("0x" + backColor[2]), "b": eval("0x" + backColor[3])};
}
else if (typeof(window.opera) == "undefined" && typeof(document.defaultView) != "undefined")
{
foreColor = document.defaultView.getComputedStyle(document.getElementById(\'smfFadeScroller\'), null).color.match(/rgb\((\d+), (\d+), (\d+)\)/);
smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

backEl = document.getElementById(\'smfFadeScroller\');
while (document.defaultView.getComputedStyle(backEl, null).backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
backEl = backEl.parentNode;

backColor = document.defaultView.getComputedStyle(backEl, null).backgroundColor.match(/rgb\((\d+), (\d+), (\d+)\)/);
smfFadeTo = {"r": parseInt(backColor[1]), "g": parseInt(backColor[2]), "b": parseInt(backColor[3])};
}

// List all the lines of the news for display.
var smfFadeContent = new Array(
"'
implode('",
"'
$context['fader_news_lines']), '"
);
// ]]></script>
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/fader.js"></script>
</td>
</tr>
</table>'
;
}

/* Each category in categories is made up of:
id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down iamge),
and boards. (see below.) */
$first true;
foreach ($context['categories'] as $category)
{
echo '
<div class="tborder" style="margin-top: ' 
$first '0;' '1ex;' '' $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'width: 100%;' '''">
<div class="catbg'
$category['new'] ? '2' '''" style="padding: 5px 5px 5px 10px;">';
$first false;

// If this category even can collapse, show a link to collapse it.
if ($category['can_collapse'])
echo '
<span style="float:right; margin-right:15px;"><a href="'
$category['collapse_href'], '"><img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/', !$category['is_collapsed'] ? 'collapse.gif' 'expand.gif''" alt="*" /></a></span>';

echo '
<span style="margin-left:80px;">'
$category['link'], '</span>
</div>'
;




// Assuming the category hasn't been collapsed...
if (!$category['is_collapsed'])
{
echo '
<table border="0" width="100%" cellspacing="1" cellpadding="5" class="bordercolor" style="margin-top: 0px;">

'
,
empty($settings['boardname_posts_lastposts_nodisplay']) ? '<tr>
<td class="titlebg3" width="51" align="center" valign="middle">

</td>
<td class="titlebg3">
'
$txt[20].'
</td>
<td class="titlebg3" valign="middle" align="center" style="width: 12ex;">
'
$txt[21].'
</td>
<td class="titlebg3" valign="middle" align="center" width="22%">
'
$txt[22].'
</td>
</tr>' 
'' ;

/* Each board in each category's boards has:
new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
foreach ($category['boards'] as $board)
{
echo '
<tr>
<td class="windowbg" width="51" align="center" valign="middle"><a href="'
$scripturl'?action=unread;board='$board['id'], '.0">';

// If the board is new, show a strong indicator.
if ($board['new'])
echo '<img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/on.gif" alt="'$txt[333], '" title="'$txt[333], '" />';
// This board doesn't have new posts, but its children do.
elseif ($board['children_new'])
echo '<img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/on2.gif" alt="'$txt[333], '" title="'$txt[333], '" />';
// No new posts at all! The agony!!
else
echo '<img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/off.gif" alt="'$txt[334], '" title="'$txt[334], '" />';

echo '</a>
</td>
<td class="windowbg2" style="padding-top:12px; padding-bottom:12px;">
<b><a href="'
$board['href'], '" name="b'$board['id'], '">'$board['name'], '</a></b><br />
'
$board['description'];

// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
if (!empty($board['moderators']))
echo '
<div style="padding-top: 1px;" class="smalltext"><br/><i>'
count($board['moderators']) == $txt[298] : $txt[299], ': 'implode(', '$board['link_moderators']), '</i></div>';

// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
if (!empty($board['children']))
{
// Sort the links into an array with new boards bold so it can be imploded.
$children = array();
/* Each child in each board's children has:
id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
foreach ($board['children'] as $child)
{
$child['link'] = '<a href="' $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' $txt[330] . ': ' $child['topics'] . ', ' $txt[21] . ': ' $child['posts'] . ')">' $child['name'] . '</a>';
$children[] = $child['new'] ? '<img style="margin-right:5px;" src="' $settings['images_url'] . '/' $settings['theme_main_color'] . '/onk.gif" alt="' $txt[333] . '"/><b>' $child['link'] . '</b>' '<img style="margin-right:5px;" src="' $settings['images_url'] . '/' $settings['theme_main_color'] . '/offk.gif" alt="' $txt[334] . '"/>' $child['link'];
}

echo '
<table style="float:right; margin-top: 15px;" width="100%" cellspacing="0" cellpadding="3" border="0">
<tr>
<td class="middletext" valign="middle" align="center" width="30%">
<b>'
$txt['parent_boards'], ':</b>
'
;

$child_counter 0;

if(empty($settings['child_boards_rows']))
{
echo '
</td>
<td class="middletext" valign="top">'
;

for(; $child_counter ceil(count($children)/2); $child_counter++)
echo $children[$child_counter], '<br/>';
}

echo '
</td>
<td class="middletext" valign="top">'
;
for(; $child_counter count($children); $child_counter++)
echo $children[$child_counter], '<br/>';
echo '
</td>
</tr>
</table>'
;
}
// Show some basic information about the number of posts, etc.
echo '
</td>
<td class="windowbg" valign="middle" align="center" style="width: 12ex;"><span class="smalltext">
'
$board['posts'], ' '$txt[21], ' <br />
'
$board['topics'],' '$txt[330], '
</span></td>
<td class="windowbg2" valign="middle" width="22%">
<span class="smalltext">'
;

/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
echo '
<b>'
$txt[22], '</b>  '$txt[525], ' '$board['last_post']['member']['link'] , '<br />
'
$txt['smf88'], ' '$board['last_post']['link'], '<br />
'
$txt[30], ' '$board['last_post']['time'];
echo '
</span>
</td>
</tr>'
;
}
echo '
</table>'
;
}
echo '
</div>'
;
}

if ($context['user']['is_logged'])
{
echo '
<table border="0" width="100%" cellspacing="0" cellpadding="5">
<tr>
<td align="'
, !$context['right_to_left'] ? 'left' 'right''" class="smalltext">
<img src="' 
$settings['images_url'] . '/'$settings['theme_main_color'] . '/new_some.gif" alt="" align="middle" /> '$txt[333], '
<img src="' 
$settings['images_url'] . '/'$settings['theme_main_color'] . '/new_none.gif" alt="" align="middle" style="margin-left: 4ex;" /> '$txt[334], '
</td>
<td align="'
, !$context['right_to_left'] ? 'right' 'left''">';

// Mark read button.
$mark_read_button = array('markread' => array('text' => 452'image' => 'markread.gif''lang' => true'url' => $scripturl '?action=markasread;sa=all;sesc=' $context['session_id']));

// Show the mark all as read button?
if ($settings['show_mark_read'] && !empty($context['categories']))
echo '
<table cellpadding="0" cellspacing="0" border="0" style="position: relative; top: 0px;">
<tr>
 '
template_button_strip($mark_read_button'top'), '
</tr>
</table>'
;
echo '
</td>
</tr>
</table>'
;
}
// Adsense before info center.
    
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
                        <td valign="top" width="85%" height="100%" class="windowbg2">
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al";
//2007-02-18: midessa-forum-468x15
google_ad_channel = "8866871717";
google_color_border = "423935";
google_color_bg = "423935";
google_color_link = "D0D0D0";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
<td valign="top" width="85%" height="100%" class="windowbg">
<br />
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<br />
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-468x60
google_ad_channel = "8764535480";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br><br />
</div>
<br />
</td>
</tr>
</table>'
;
// End Adsense before info center.
// Here's where the "Info Center" starts...
echo '<br />
<div class="tborder" '
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' '''>
<div class="catbg" style="padding: 6px; vertical-align: middle; text-align: center; ">
<a href="#" onclick="shrinkHeaderIC(!current_header_ic); return false;"><img id="upshrink_ic" src="'
$settings['images_url'] . '/'$settings['theme_main_color'], '/', empty($options['collapse_header_ic']) ? 'collapse.gif' 'expand.gif''" alt="*" title="'$txt['upshrink_description'], '" style="margin-right: 2ex;" align="right" /></a>
'
$txt[685], '
</div>
<div id="upshrinkHeaderIC"'
, empty($options['collapse_header_ic']) ? '' ' style="display: none;"''>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">'
;

// This is the "Recent Posts" bar.
if (!empty($settings['number_recent_posts']))
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[214], '</td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="'
$scripturl'?action=recent"><img src="'$settings['images_url'], '/post/xx.gif" alt="'$txt[214], '" /></a>
</td>
<td class="windowbg2">'
;

// Only show one post.
if ($settings['number_recent_posts'] == 1)
{
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<b><a href="'
$scripturl'?action=recent">'$txt[214], '</a></b>
<div class="smalltext">
'
$txt[234], ' "'$context['latest_post']['link'], '" '$txt[235], ' ('$context['latest_post']['time'], ')<br />
</div>'
;
}
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<table cellpadding="0" cellspacing="0" width="100%">'
;

/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<tr>
<td class="windowbg" valign="middle" width="40%" style="padding-left: 10px; font-size:85%">'
$post['link'], '</td>
<td class="windowbg" valign="middle" width="15%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">'
$post['poster']['link'], '</td>
<td class="windowbg" valign="middle" width="25%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">'
$post['board']['link'], '</td>
<td class="windowbg" valign="middle" width="20%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">'
$post['time'], '</td>

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

// Show information about events, birthdays, and holidays on the calendar.
if ($context['show_calendar'])
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$context['calendar_only_today'] ? $txt['calendar47b'] : $txt['calendar47'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="'
$scripturl'?action=calendar"><img src="'$settings['images_url'], '/icons/calendar.gif" alt="'$txt['calendar24'], '" /></a>
</td>
<td class="windowbg2" width="100%">
<span class="smalltext">'
;

// Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P.
if (!empty($context['calendar_holidays']))
echo '
<span style="color: #'
$modSettings['cal_holidaycolor'], ';">'$txt['calendar5'], ' 'implode(', '$context['calendar_holidays']), '</span><br />';

// People's birthdays. Like mine. And yours, I guess. Kidding.
if (!empty($context['calendar_birthdays']))
{
echo '
<span style="color: #'
$modSettings['cal_bdaycolor'], ';">'$context['calendar_only_today'] ? $txt['calendar3'] : $txt['calendar3b'], '</span> ';
/* Each member in calendar_birthdays has:
id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) */
foreach ($context['calendar_birthdays'] as $member)
echo '
<a href="'
$scripturl'?action=profile;u='$member['id'], '">'$member['is_today'] ? '<b>' ''$member['name'], $member['is_today'] ? '</b>' '', isset($member['age']) ? ' (' $member['age'] . ')' '''</a>'$member['is_last'] ? '<br />' ', ';
}
// Events like community get-togethers.
if (!empty($context['calendar_events']))
{
echo '
<span style="color: #'
$modSettings['cal_eventcolor'], ';">'$context['calendar_only_today'] ? $txt['calendar4'] : $txt['calendar4b'], '</span> ';
/* Each event in calendar_events should have:
title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
foreach ($context['calendar_events'] as $event)
echo '
'
$event['can_edit'] ? '<a href="' $event['modify_href'] . '" style="color: #FF0000;">*</a> ' ''$event['href'] == '' '' '<a href="' $event['href'] . '">'$event['is_today'] ? '<b>' $event['title'] . '</b>' $event['title'], $event['href'] == '' '' '</a>'$event['is_last'] ? '<br />' ', ';

// Show a little help text to help them along ;).
if ($context['calendar_can_edit'])
echo '
(<a href="'
$scripturl'?action=helpadmin;help=calendar_how_edit" onclick="return reqWin(this.href);">'$txt['calendar_how_edit'], '</a>)';
}
echo '
</span>
</td>
</tr>'
;
}


// Show YaBB SP1 style information...
if ($settings['show_sp1_info'])
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[645], '</td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="'
$scripturl'?action=stats"><img src="'$settings['images_url'], '/icons/info.gif" alt="'$txt[645], '" /></a>
</td>
<td class="windowbg2" width="100%">
<span class="middletext">
'
$context['common_stats']['total_posts'], ' '$txt[95], ' '$txt['smf88'], ' '$context['common_stats']['total_topics'], ' '$txt[64], ' '$txt[525], ' '$context['common_stats']['total_members'], ' '$txt[19], '. '$txt[656], ': <b> '$context['common_stats']['latest_member']['link'], '</b>
<br /> ' 
$txt[659] . ': <b>"' $context['latest_post']['link'] . '"</b>  ( ' $context['latest_post']['time'] . ' )<br />
<a href="'
$scripturl'?action=recent">'$txt[234], '</a>'$context['show_stats'] ? '<br />
<a href="' 
$scripturl '?action=stats">' $txt['smf223'] . '</a>' '''
</span>
</td>
</tr>'
;
}

// "Users online" - in order of activity.
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[158], '</td>
</tr><tr>
<td rowspan="2" class="windowbg" width="20" valign="middle" align="center">
'
$context['show_who'] ? '<a href="' $scripturl '?action=who">' '''<img src="'$settings['images_url'], '/icons/online.gif" alt="'$txt[158], '" />'$context['show_who'] ? '</a>' '''
</td>
<td class="windowbg2" width="100%">'
;

echo '
'
$context['show_who'] ? '<a href="' $scripturl '?action=who">' ''$context['num_guests'], ' '$context['num_guests'] == $txt['guest'] : $txt['guests'], ', ' $context['num_users_online'], ' '$context['num_users_online'] == $txt['user'] : $txt['users'];

// Handle hidden users and buddies.
if (!empty($context['num_users_hidden']) || ($context['show_buddies'] && !empty($context['show_buddies'])))
{
echo ' (';

// Show the number of buddies online?
if ($context['show_buddies'])
echo $context['num_buddies'], ' '$context['num_buddies'] == $txt['buddy'] : $txt['buddies'];

// How about hidden users?
if (!empty($context['num_users_hidden']))
echo $context['show_buddies'] ? ', ' ''$context['num_users_hidden'] . ' ' $txt['hidden'];

echo ')';
}

echo $context['show_who'] ? '</a>' '''
<div class="smalltext">'
;

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
echo '
'
$txt[140], ':<br />'implode(', '$context['list_users_online']);

echo '
<br />
'
$context['show_stats'] && !$settings['show_sp1_info'] ? '<a href="' $scripturl '?action=stats">' $txt['smf223'] . '</a>' '''
</div>
</td>
</tr>
<tr>
<td class="windowbg2" width="100%">
<span class="middletext">
'
$txt['most_online_today'], ': <b>'$modSettings['mostOnlineToday'], '</b>.
'
$txt['most_online_ever'], ': '$modSettings['mostOnline'], ' (' timeformat($modSettings['mostDate']), ')
</span>
</td>
</tr>'
;

// If they are logged in, but SP1 style information is off... show a personal message bar.
if ($context['user']['is_logged'] && !$settings['show_sp1_info'])
{
 echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[159], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
'
$context['allow_pm'] ? '<a href="' $scripturl '?action=pm">' '''<img src="'$settings['images_url'], '/message_sm.gif" alt="'$txt[159], '" />'$context['allow_pm'] ? '</a>' '''
</td>
<td class="windowbg2" valign="top">
<b><a href="'
$scripturl'?action=pm">'$txt[159], '</a></b>
<div class="smalltext">
'
$txt[660], ' '$context['user']['messages'], ' '$context['user']['messages'] == $txt[471] : $txt[153], '.... '$txt[661], ' <a href="'$scripturl'?action=pm">'$txt[662], '</a> '$txt[663], '
</div>
</td>
</tr>'
;
}

// Show the login bar. (it's only true if they are logged out anyway.)
if ($context['show_login_bar'])
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[34], ' <a href="'$scripturl'?action=reminder" class="smalltext">(' $txt[315] . ')</a></td>
</tr>
<tr>
<td class="windowbg" width="20" align="center">
<a href="'
$scripturl'?action=login"><img src="'$settings['images_url'], '/icons/login.gif" alt="'$txt[34], '" /></a>
</td>
<td class="windowbg2" valign="middle">
<form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" style="margin: 0;">
<table border="0" cellpadding="2" cellspacing="0" align="center" width="100%"><tr>
<td valign="middle" align="left">
<label for="user"><b>'
$txt[35], ':</b><br />
<input type="text" name="user" id="user" size="15" /></label>
</td>
<td valign="middle" align="left">
<label for="passwrd"><b>'
$txt[36], ':</b><br />
<input type="password" name="passwrd" id="passwrd" size="15" /></label>
</td>
<td valign="middle" align="left">
<label for="cookielength"><b>'
$txt[497], ':</b><br />
<input type="text" name="cookielength" id="cookielength" size="4" maxlength="4" value="'
$modSettings['cookieTime'], '" /></label>
</td>
<td valign="middle" align="left">
<label for="cookieneverexp"><b>'
$txt[508], ':</b><br />
<input type="checkbox" name="cookieneverexp" id="cookieneverexp" checked="checked" class="check" /></label>
</td>
<td valign="middle" align="left">
<input type="submit" value="'
$txt[34], '" />
</td>
</tr></table>
</form>
</td>
</tr>'
;
}

echo '
</table>
</div>
</div>'
;
}

?>


If you want just a working boardindex.template.php try:
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Fiery on January 11, 2008, 01:08:00 AM
<?php
// Version: 1.1; BoardIndex

function template_main()
{
global $context$settings$options$txt$scripturl$modSettings;

// Show some statistics next to the link tree if SP1 info is off.
echo '
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom">'
theme_linktree(), '</td>
<td align="right">'
;
if (!$settings['show_sp1_info'])
echo '
'
$txt[19], ': '$context['common_stats']['total_members'], ' &nbsp;&#38;#8226;&nbsp; '$txt[95], ': '$context['common_stats']['total_posts'], ' &nbsp;&#38;#8226;&nbsp; '$txt[64], ': '$context['common_stats']['total_topics'], '
'
, ($settings['show_latest_member'] ? '<br />' $txt[201] . ' <b>' $context['common_stats']['latest_member']['link'] . '</b>' $txt[581] : '');
echo '
</td>
</tr>
</table>'
;

// Show the news fader?  (assuming there are things to show...)
if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
{
echo '
<table border="0" width="100%" class="tborder" cellspacing="' 
, ($context['browser']['is_ie'] || $context['browser']['is_opera6']) ? '1' '0' '" cellpadding="4" style="margin-bottom: 2ex;">
<tr>
<td valign="middle" align="center" height="60" class="windowbg2">'
;

// Prepare all the javascript settings.
echo '
<div id="smfFadeScroller" style="width: 90%; padding: 2px;"><b>'
$context['news_lines'][0], '</b></div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
// The fading delay (in ms.)
var smfFadeDelay = '
, empty($settings['newsfader_time']) ? 5000 $settings['newsfader_time'], ';
// Fade from... what text color? To which background color?
var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 255, "g": 255, "b": 255};
// Surround each item with... anything special?
var smfFadeBefore = "<b>", smfFadeAfter = "</b>";

var foreColor, backEl, backColor;

if (typeof(document.getElementById(\'smfFadeScroller\').currentStyle) != "undefined")
{
foreColor = document.getElementById(\'smfFadeScroller\').currentStyle.color.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

backEl = document.getElementById(\'smfFadeScroller\');
while (backEl.currentStyle.backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined")
backEl = backEl.parentNode;

backColor = backEl.currentStyle.backgroundColor.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
smfFadeTo = {"r": eval("0x" + backColor[1]), "g": eval("0x" + backColor[2]), "b": eval("0x" + backColor[3])};
}
else if (typeof(window.opera) == "undefined" && typeof(document.defaultView) != "undefined")
{
foreColor = document.defaultView.getComputedStyle(document.getElementById(\'smfFadeScroller\'), null).color.match(/rgb\((\d+), (\d+), (\d+)\)/);
smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

backEl = document.getElementById(\'smfFadeScroller\');
while (document.defaultView.getComputedStyle(backEl, null).backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
backEl = backEl.parentNode;

backColor = document.defaultView.getComputedStyle(backEl, null).backgroundColor.match(/rgb\((\d+), (\d+), (\d+)\)/);
smfFadeTo = {"r": parseInt(backColor[1]), "g": parseInt(backColor[2]), "b": parseInt(backColor[3])};
}

// List all the lines of the news for display.
var smfFadeContent = new Array(
"'
implode('",
"'
$context['fader_news_lines']), '"
);
// ]]></script>
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/fader.js"></script>
</td>
</tr>
</table>'
;
}

/* Each category in categories is made up of:
id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down iamge),
and boards. (see below.) */
$first true;
foreach ($context['categories'] as $category)
{
echo '
<div class="tborder" style="margin-top: ' 
$first '0;' '1ex;' '' $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'width: 100%;' '''">
<div class="catbg'
$category['new'] ? '2' '''" style="padding: 5px 5px 5px 10px;">';
$first false;

// If this category even can collapse, show a link to collapse it.
if ($category['can_collapse'])
echo '
<span style="float:right; margin-right:15px;"><a href="'
$category['collapse_href'], '"><img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/', !$category['is_collapsed'] ? 'collapse.gif' 'expand.gif''" alt="*" /></a></span>';

echo '
<span style="margin-left:80px;">'
$category['link'], '</span>
</div>'
;




// Assuming the category hasn't been collapsed...
if (!$category['is_collapsed'])
{
echo '
<table border="0" width="100%" cellspacing="1" cellpadding="5" class="bordercolor" style="margin-top: 0px;">

'
,
empty($settings['boardname_posts_lastposts_nodisplay']) ? '<tr>
<td class="titlebg3" width="51" align="center" valign="middle">

</td>
<td class="titlebg3">
'
$txt[20].'
</td>
<td class="titlebg3" valign="middle" align="center" style="width: 12ex;">
'
$txt[21].'
</td>
<td class="titlebg3" valign="middle" align="center" width="22%">
'
$txt[22].'
</td>
</tr>' 
'' ;

/* Each board in each category's boards has:
new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
foreach ($category['boards'] as $board)
{
echo '
<tr>
<td class="windowbg" width="51" align="center" valign="middle"><a href="'
$scripturl'?action=unread;board='$board['id'], '.0">';

// If the board is new, show a strong indicator.
if ($board['new'])
echo '<img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/on.gif" alt="'$txt[333], '" title="'$txt[333], '" />';
// This board doesn't have new posts, but its children do.
elseif ($board['children_new'])
echo '<img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/on2.gif" alt="'$txt[333], '" title="'$txt[333], '" />';
// No new posts at all! The agony!!
else
echo '<img src="'$settings['images_url'] . '/'$settings['theme_main_color'], '/off.gif" alt="'$txt[334], '" title="'$txt[334], '" />';

echo '</a>
</td>
<td class="windowbg2" style="padding-top:12px; padding-bottom:12px;">
<b><a href="'
$board['href'], '" name="b'$board['id'], '">'$board['name'], '</a></b><br />
'
$board['description'];

// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
if (!empty($board['moderators']))
echo '
<div style="padding-top: 1px;" class="smalltext"><br/><i>'
count($board['moderators']) == $txt[298] : $txt[299], ': 'implode(', '$board['link_moderators']), '</i></div>';

// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
if (!empty($board['children']))
{
// Sort the links into an array with new boards bold so it can be imploded.
$children = array();
/* Each child in each board's children has:
id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
foreach ($board['children'] as $child)
{
$child['link'] = '<a href="' $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' $txt[330] . ': ' $child['topics'] . ', ' $txt[21] . ': ' $child['posts'] . ')">' $child['name'] . '</a>';
$children[] = $child['new'] ? '<img style="margin-right:5px;" src="' $settings['images_url'] . '/' $settings['theme_main_color'] . '/onk.gif" alt="' $txt[333] . '"/><b>' $child['link'] . '</b>' '<img style="margin-right:5px;" src="' $settings['images_url'] . '/' $settings['theme_main_color'] . '/offk.gif" alt="' $txt[334] . '"/>' $child['link'];
}

echo '
<table style="float:right; margin-top: 15px;" width="100%" cellspacing="0" cellpadding="3" border="0">
<tr>
<td class="middletext" valign="middle" align="center" width="30%">
<b>'
$txt['parent_boards'], ':</b>
'
;

$child_counter 0;

if(empty($settings['child_boards_rows']))
{
echo '
</td>
<td class="middletext" valign="top">'
;

for(; $child_counter ceil(count($children)/2); $child_counter++)
echo $children[$child_counter], '<br/>';
}

echo '
</td>
<td class="middletext" valign="top">'
;
for(; $child_counter count($children); $child_counter++)
echo $children[$child_counter], '<br/>';
echo '
</td>
</tr>
</table>'
;
}
// Show some basic information about the number of posts, etc.
echo '
</td>
<td class="windowbg" valign="middle" align="center" style="width: 12ex;"><span class="smalltext">
'
$board['posts'], ' '$txt[21], ' <br />
'
$board['topics'],' '$txt[330], '
</span></td>
<td class="windowbg2" valign="middle" width="22%">
<span class="smalltext">'
;

/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
echo '
<b>'
$txt[22], '</b>  '$txt[525], ' '$board['last_post']['member']['link'] , '<br />
'
$txt['smf88'], ' '$board['last_post']['link'], '<br />
'
$txt[30], ' '$board['last_post']['time'];
echo '
</span>
</td>
</tr>'
;
}
echo '
</table>'
;
}
echo '
</div>'
;
}

if ($context['user']['is_logged'])
{
echo '
<table border="0" width="100%" cellspacing="0" cellpadding="5">
<tr>
<td align="'
, !$context['right_to_left'] ? 'left' 'right''" class="smalltext">
<img src="' 
$settings['images_url'] . '/'$settings['theme_main_color'] . '/new_some.gif" alt="" align="middle" /> '$txt[333], '
<img src="' 
$settings['images_url'] . '/'$settings['theme_main_color'] . '/new_none.gif" alt="" align="middle" style="margin-left: 4ex;" /> '$txt[334], '
</td>
<td align="'
, !$context['right_to_left'] ? 'right' 'left''">';

// Mark read button.
$mark_read_button = array('markread' => array('text' => 452'image' => 'markread.gif''lang' => true'url' => $scripturl '?action=markasread;sa=all;sesc=' $context['session_id']));

// Show the mark all as read button?
if ($settings['show_mark_read'] && !empty($context['categories']))
echo '
<table cellpadding="0" cellspacing="0" border="0" style="position: relative; top: 0px;">
<tr>
 '
template_button_strip($mark_read_button'top'), '
</tr>
</table>'
;
echo '
</td>
</tr>
</table>'
;
}

// Here's where the "Info Center" starts...
echo '<br />
<div class="tborder" '
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' '''>
<div class="catbg" style="padding: 6px; vertical-align: middle; text-align: center; ">
<a href="#" onclick="shrinkHeaderIC(!current_header_ic); return false;"><img id="upshrink_ic" src="'
$settings['images_url'] . '/'$settings['theme_main_color'], '/', empty($options['collapse_header_ic']) ? 'collapse.gif' 'expand.gif''" alt="*" title="'$txt['upshrink_description'], '" style="margin-right: 2ex;" align="right" /></a>
'
$txt[685], '
</div>
<div id="upshrinkHeaderIC"'
, empty($options['collapse_header_ic']) ? '' ' style="display: none;"''>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">'
;

// This is the "Recent Posts" bar.
if (!empty($settings['number_recent_posts']))
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[214], '</td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="'
$scripturl'?action=recent"><img src="'$settings['images_url'], '/post/xx.gif" alt="'$txt[214], '" /></a>
</td>
<td class="windowbg2">'
;

// Only show one post.
if ($settings['number_recent_posts'] == 1)
{
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<b><a href="'
$scripturl'?action=recent">'$txt[214], '</a></b>
<div class="smalltext">
'
$txt[234], ' &quot;'$context['latest_post']['link'], '&quot; '$txt[235], ' ('$context['latest_post']['time'], ')<br />
</div>'
;
}
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<table cellpadding="0" cellspacing="0" width="100%">'
;

/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<tr>
<td class="windowbg" valign="middle" width="40%" style="padding-left: 10px; font-size:85%">'
$post['link'], '</td>
<td class="windowbg" valign="middle" width="15%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">'
$post['poster']['link'], '</td>
<td class="windowbg" valign="middle" width="25%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">'
$post['board']['link'], '</td>
<td class="windowbg" valign="middle" width="20%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">'
$post['time'], '</td>

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

// Show information about events, birthdays, and holidays on the calendar.
if ($context['show_calendar'])
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$context['calendar_only_today'] ? $txt['calendar47b'] : $txt['calendar47'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="'
$scripturl'?action=calendar"><img src="'$settings['images_url'], '/icons/calendar.gif" alt="'$txt['calendar24'], '" /></a>
</td>
<td class="windowbg2" width="100%">
<span class="smalltext">'
;

// Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P.
if (!empty($context['calendar_holidays']))
echo '
<span style="color: #'
$modSettings['cal_holidaycolor'], ';">'$txt['calendar5'], ' 'implode(', '$context['calendar_holidays']), '</span><br />';

// People's birthdays. Like mine. And yours, I guess. Kidding.
if (!empty($context['calendar_birthdays']))
{
echo '
<span style="color: #'
$modSettings['cal_bdaycolor'], ';">'$context['calendar_only_today'] ? $txt['calendar3'] : $txt['calendar3b'], '</span> ';
/* Each member in calendar_birthdays has:
id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) */
foreach ($context['calendar_birthdays'] as $member)
echo '
<a href="'
$scripturl'?action=profile;u='$member['id'], '">'$member['is_today'] ? '<b>' ''$member['name'], $member['is_today'] ? '</b>' '', isset($member['age']) ? ' (' $member['age'] . ')' '''</a>'$member['is_last'] ? '<br />' ', ';
}
// Events like community get-togethers.
if (!empty($context['calendar_events']))
{
echo '
<span style="color: #'
$modSettings['cal_eventcolor'], ';">'$context['calendar_only_today'] ? $txt['calendar4'] : $txt['calendar4b'], '</span> ';
/* Each event in calendar_events should have:
title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
foreach ($context['calendar_events'] as $event)
echo '
'
$event['can_edit'] ? '<a href="' $event['modify_href'] . '" style="color: #FF0000;">*</a> ' ''$event['href'] == '' '' '<a href="' $event['href'] . '">'$event['is_today'] ? '<b>' $event['title'] . '</b>' $event['title'], $event['href'] == '' '' '</a>'$event['is_last'] ? '<br />' ', ';

// Show a little help text to help them along ;).
if ($context['calendar_can_edit'])
echo '
(<a href="'
$scripturl'?action=helpadmin;help=calendar_how_edit" onclick="return reqWin(this.href);">'$txt['calendar_how_edit'], '</a>)';
}
echo '
</span>
</td>
</tr>'
;
}


// Show YaBB SP1 style information...
if ($settings['show_sp1_info'])
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[645], '</td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="'
$scripturl'?action=stats"><img src="'$settings['images_url'], '/icons/info.gif" alt="'$txt[645], '" /></a>
</td>
<td class="windowbg2" width="100%">
<span class="middletext">
'
$context['common_stats']['total_posts'], ' '$txt[95], ' '$txt['smf88'], ' '$context['common_stats']['total_topics'], ' '$txt[64], ' '$txt[525], ' '$context['common_stats']['total_members'], ' '$txt[19], '. '$txt[656], ': <b> '$context['common_stats']['latest_member']['link'], '</b>
<br /> ' 
$txt[659] . ': <b>&quot;' $context['latest_post']['link'] . '&quot;</b>  ( ' $context['latest_post']['time'] . ' )<br />
<a href="'
$scripturl'?action=recent">'$txt[234], '</a>'$context['show_stats'] ? '<br />
<a href="' 
$scripturl '?action=stats">' $txt['smf223'] . '</a>' '''
</span>
</td>
</tr>'
;
}

// "Users online" - in order of activity.
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[158], '</td>
</tr><tr>
<td rowspan="2" class="windowbg" width="20" valign="middle" align="center">
'
$context['show_who'] ? '<a href="' $scripturl '?action=who">' '''<img src="'$settings['images_url'], '/icons/online.gif" alt="'$txt[158], '" />'$context['show_who'] ? '</a>' '''
</td>
<td class="windowbg2" width="100%">'
;

echo '
'
$context['show_who'] ? '<a href="' $scripturl '?action=who">' ''$context['num_guests'], ' '$context['num_guests'] == $txt['guest'] : $txt['guests'], ', ' $context['num_users_online'], ' '$context['num_users_online'] == $txt['user'] : $txt['users'];

// Handle hidden users and buddies.
if (!empty($context['num_users_hidden']) || ($context['show_buddies'] && !empty($context['show_buddies'])))
{
echo ' (';

// Show the number of buddies online?
if ($context['show_buddies'])
echo $context['num_buddies'], ' '$context['num_buddies'] == $txt['buddy'] : $txt['buddies'];

// How about hidden users?
if (!empty($context['num_users_hidden']))
echo $context['show_buddies'] ? ', ' ''$context['num_users_hidden'] . ' ' $txt['hidden'];

echo ')';
}

echo $context['show_who'] ? '</a>' '''
<div class="smalltext">'
;

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
echo '
'
$txt[140], ':<br />'implode(', '$context['list_users_online']);

echo '
<br />
'
$context['show_stats'] && !$settings['show_sp1_info'] ? '<a href="' $scripturl '?action=stats">' $txt['smf223'] . '</a>' '''
</div>
</td>
</tr>
<tr>
<td class="windowbg2" width="100%">
<span class="middletext">
'
$txt['most_online_today'], ': <b>'$modSettings['mostOnlineToday'], '</b>.
'
$txt['most_online_ever'], ': '$modSettings['mostOnline'], ' (' timeformat($modSettings['mostDate']), ')
</span>
</td>
</tr>'
;

// If they are logged in, but SP1 style information is off... show a personal message bar.
if ($context['user']['is_logged'] && !$settings['show_sp1_info'])
{
 echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[159], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
'
$context['allow_pm'] ? '<a href="' $scripturl '?action=pm">' '''<img src="'$settings['images_url'], '/message_sm.gif" alt="'$txt[159], '" />'$context['allow_pm'] ? '</a>' '''
</td>
<td class="windowbg2" valign="top">
<b><a href="'
$scripturl'?action=pm">'$txt[159], '</a></b>
<div class="smalltext">
'
$txt[660], ' '$context['user']['messages'], ' '$context['user']['messages'] == $txt[471] : $txt[153], '.... '$txt[661], ' <a href="'$scripturl'?action=pm">'$txt[662], '</a> '$txt[663], '
</div>
</td>
</tr>'
;
}

// Show the login bar. (it's only true if they are logged out anyway.)
if ($context['show_login_bar'])
{
echo '
<tr>
<td class="titlebg" colspan="2">'
$txt[34], ' <a href="'$scripturl'?action=reminder" class="smalltext">(' $txt[315] . ')</a></td>
</tr>
<tr>
<td class="windowbg" width="20" align="center">
<a href="'
$scripturl'?action=login"><img src="'$settings['images_url'], '/icons/login.gif" alt="'$txt[34], '" /></a>
</td>
<td class="windowbg2" valign="middle">
<form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" style="margin: 0;">
<table border="0" cellpadding="2" cellspacing="0" align="center" width="100%"><tr>
<td valign="middle" align="left">
<label for="user"><b>'
$txt[35], ':</b><br />
<input type="text" name="user" id="user" size="15" /></label>
</td>
<td valign="middle" align="left">
<label for="passwrd"><b>'
$txt[36], ':</b><br />
<input type="password" name="passwrd" id="passwrd" size="15" /></label>
</td>
<td valign="middle" align="left">
<label for="cookielength"><b>'
$txt[497], ':</b><br />
<input type="text" name="cookielength" id="cookielength" size="4" maxlength="4" value="'
$modSettings['cookieTime'], '" /></label>
</td>
<td valign="middle" align="left">
<label for="cookieneverexp"><b>'
$txt[508], ':</b><br />
<input type="checkbox" name="cookieneverexp" id="cookieneverexp" checked="checked" class="check" /></label>
</td>
<td valign="middle" align="left">
<input type="submit" value="'
$txt[34], '" />
</td>
</tr></table>
</form>
</td>
</tr>'
;
}

echo '
</table>
</div>
</div>'
;
}

?>


Or the easiest things you could do is install the ad management mod (http://custom.simplemachines.org/mods/index.php?mod=255) and see if that can handle it for you.

Note:  I did not see any mods installed that made use of coding in boardindex.template.php, but I could have missed it.  If one of your mods quits working that change could be why.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: _Dale_ on January 11, 2008, 05:03:45 AM
Thanks for the replies. I will try this when I return home. Will be sure to update :).

Cheers,
Dale.

UPDATE: Seems to have worked nicely :).
Thanks a lot guys,
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Fiery on January 12, 2008, 07:01:52 PM
Sounds good, glad to hear its working!
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: usa4all on February 15, 2008, 03:17:37 PM
Quote from: cru on September 15, 2007, 08:21:57 AM
hi, i tried the part :
QuoteDisplay.template.php -- Puts adsense after EVERY first post.

in this thread's first post. but i have a question.

I put something else instead of the google ads after the first message. (a own sponsormessage)
Is it possible also add a ad or sponsor message after the ,for example, 5th message?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Free Town on March 07, 2008, 09:21:38 AM
i love you this is great :)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: happybear on June 11, 2008, 12:39:06 AM
As per the first post, I added in the script to put adsense on Board Index, before Info Center (after deleting the first replicated part) but my ads do not show.

I'm very new here so please bear with me. I'm using a 1.1.4 so which mod should I be downloading in http://custom.simplemachines.org/mods/index.php?mod=255? And which file should I be uploading it to? Is it the same location as my forum (any specific folder)?

Will appreciate if I can get any help here. Cheers
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: LilMermaidGirl on June 12, 2008, 05:36:16 PM
Hi, I am using the 1st suggest method here. I got it to work on my forums finally, but it is displayed a tiny bit too high. In the image you can see where the adsense is at, and I drew a pink line displaying where I'd like it to be (below the Home, Forums, My Messages, etc. links).

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi279.photobucket.com%2Falbums%2Fkk128%2FLilMermaidGirl%2Fadsenseex.jpg&hash=e753011f6788347e7eb9afc13c23701755c5855e)

Is it possible to get it to moved down a bit at all? I'm using smf 1.5 and absado_v2 theme, not sure if that matters.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: philip_ulrich on June 18, 2008, 01:10:05 AM
i did what you said and i got this

Template Parse Error!
There was a problem loading the /Themes/default/Display.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
syntax error, unexpected $end

help...
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: red panther on July 27, 2008, 07:37:02 AM
Great topic, it helped me much
but i still wanna know:
1- how to add asense in the footer of each page like this forum?
2- how to place adsense in a vertical manner in the right side of every page ?
please i want it like codes in 1st post in this topic as i don't like ad manager
thanx
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: SpoogeBeast on September 01, 2008, 08:45:06 PM
Think I'll try the ad mod first then come back to the other tips if I need to. Thanks nite0859 for posting this!
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Mick. on December 23, 2008, 08:05:26 PM
Anyone placed any ads in Private Messages?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Big Enis on February 07, 2009, 11:18:33 AM
What does it mean when you add code to index.php and query it?  I am doing the Ad Management Mod for 1.1.8 that Jerm wrote, and am at that point.

Thanks

Simple Machines Rocks!

George
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Big Enis on February 07, 2009, 11:26:17 AM
What does it mean when you add code to index.php and query it?  I am doing the Ad Management Mod for 1.1.8 that Jerm wrote, and am at that point.

Thanks

Simple Machines Rocks!

George
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: ken123 on February 21, 2009, 11:36:27 AM
How do I put adsense on the last post of the thread? Thanks.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: vegetablegod on April 23, 2009, 07:35:56 AM
I got the other two to work, but I'd really like to use the one for index.template.php so I can just have it on every page. This is my code, is there anything wrong with it?...

<table align="center" width="71%" cellpadding="5" cellspacing="0" style="table-layout: fixed;" class="windowbg">
<tr>
<td valign="top" width="85%" height="100%">
<div style="overflow: auto; width: 100%;" align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-1149010504046487";
/* 728x90, created 4/23/09 */
google_ad_slot = "7012000478";
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>


Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: JBlaze on April 24, 2009, 05:22:01 AM
Quote from: ken123 on February 21, 2009, 11:36:27 AM
How do I put adsense on the last post of the thread? Thanks.

You can install the Ad Management (http://custom.simplemachines.org/mods/index.php?mod=255) mod to add it the end if posts as well as other places.

Quote from: vegetablegod on April 23, 2009, 07:35:56 AM
I got the other two to work, but I'd really like to use the one for index.template.php so I can just have it on every page. This is my code, is there anything wrong with it?...

<table align="center" width="71%" cellpadding="5" cellspacing="0" style="table-layout: fixed;" class="windowbg">
<tr>
<td valign="top" width="85%" height="100%">
<div style="overflow: auto; width: 100%;" align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-1149010504046487";
/* 728x90, created 4/23/09 */
google_ad_slot = "7012000478";
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>




for this, are you trying to place this inside index.template.php? Is so, you will need to format it to integrate into the php file. If you can provide a copy of your index.template.php file and let me know where you would like to put it, I can do it for you.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: vegetablegod on April 24, 2009, 06:43:54 AM
I just want to add it to the top of every page. And yes, I am adding it to index.template.php


index.template.php
File Type: PHP script text
<?php
// Version: 1.1.5; index

/* This template is, perhaps, the most important template in the theme. It
contains the main template layer that displays the header and footer of
the forum, namely with main_above and main_below. It also contains the
menu sub template, which appropriately displays the menu; the init sub
template, which is there to set the theme up; (init can be missing.) and
the linktree sub template, which sorts out the link tree.

The init sub template should load any data and set any hardcoded options.

The main_above sub template is what is shown above the main content, and
should contain anything that should be shown up there.

The main_below sub template, conversely, is shown after the main content.
It should probably contain the copyright statement and some other things.

The linktree sub template should display the link tree, using the data
in the $context['linktree'] variable.

The menu sub template should display all the relevant buttons the user
wants and or needs.

For more information on the templating system, please see the site at:
http://www.simplemachines.org/
*/

// Initialize the template... mainly little settings.
function template_init()
{
global $context$settings$options$txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '1.1';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;

/* Show sticky and lock status seperate from topic icons? */
$settings['seperate_sticky_lock'] = true;
}

// The main sub template above the content.
function template_main_above()
{
global $context$settings$options$scripturl$txt$modSettings;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''><head>
<meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
<meta name="description" content="'
$context['page_title'], '" />', empty($context['robot_no_index']) ? '' '
<meta name="robots" content="noindex" />'
'
<meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/script.js?fin11"></script>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var smf_theme_url = "'
$settings['theme_url'], '";
var smf_images_url = "'
$settings['images_url'], '";
var smf_scripturl = "'
$scripturl'";
var smf_iso_case_folding = '
$context['server']['iso_case_folding'] ? 'true' 'false'';
var smf_charset = "'
$context['character_set'], '";
// ]]></script>
<title>'
$context['page_title'], '</title>';

// The ?fin11 part of this link is just here to make sure browsers don't cache it wrongly.
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/style.css?fin11" />
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/print.css?fin11" media="print" />';

/* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
Standards compliance mode happens when you use xhtml... */
if ($context['browser']['needs_size_fix'])
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/fonts-compat.css" />';

// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="'
$scripturl'?action=help" target="_blank" />
<link rel="search" href="' 
$scripturl '?action=search" />
<link rel="contents" href="'
$scripturl'" />';

// If RSS feeds are enabled, advertise the presence of one.
if (!empty($modSettings['xmlnews_enable']))
echo '
<link rel="alternate" type="application/rss+xml" title="'
$context['forum_name'], ' - RSS" href="'$scripturl'?type=rss;action=.xml" />';

// If we're viewing a topic, these should be the previous and next topics, respectively.
if (!empty($context['current_topic']))
echo '
<link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
<link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board']))
echo '
<link rel="index" href="' 
$scripturl '?board=' $context['current_board'] . '.0" />';

// We'll have to use the cookie to remember the header...
if ($context['user']['is_guest'])
{
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
}

// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'], '

<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var current_header = '
, empty($options['collapse_header']) ? 'false' 'true'';

function shrinkHeader(mode)
{'
;

// Guests don't have theme options!!
if ($context['user']['is_guest'])
echo '
document.cookie = "upshrink=" + (mode ? 1 : 0);'
;
else
echo '
smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "'
$context['session_id'], '");';

echo '
document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");

document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";
document.getElementById("upshrinkHeader2").style.display = mode ? "none" : "";

current_header = mode;
}
// ]]></script>'
;

// the routine for the info center upshrink
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var current_header_ic = '
, empty($options['collapse_header_ic']) ? 'false' 'true'';

function shrinkHeaderIC(mode)
{'
;

if ($context['user']['is_guest'])
echo '
document.cookie = "upshrinkIC=" + (mode ? 1 : 0);'
;
else
echo '
smf_setThemeOption("collapse_header_ic", mode ? 1 : 0, null, "'
$context['session_id'], '");';

echo '
document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";

current_header_ic = mode;
}
// ]]></script>
</head>
<body>'
;

echo '
<div class="tborder" '
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? ' style="width: 100%;"' '''>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="catbg" height="32">'
;

if (empty($settings['header_logo_url']))
echo '
<span style="font-family: Verdana, sans-serif; font-size: 140%; ">'
$context['forum_name'], '</span>';
else
echo '
<img src="'
$settings['header_logo_url'], '" style="margin: 4px;" alt="'$context['forum_name'], '" />';

echo '
</td>
<td align="right" class="catbg">
<img src="'
$settings['images_url'], '/smflogo.gif" style="margin: 2px;" alt="" />
</td>
</tr>
</table>'
;




// display user name
echo '
<table width="100%" cellpadding="0" cellspacing="0" border="0" >
<tr>'
;

if($context['user']['is_logged'])
echo '
<td class="titlebg2" height="32">
<span style="font-size: 130%;"> '
$txt['hello_member_ndt'], ' <b>'$context['user']['name'] , '</b></span>
</td>'
;

// display the time
echo '
<td class="titlebg2" height="32" align="right">
<span class="smalltext">' 
$context['current_time'], '</span>';

// this is the upshrink button for the user info section
echo '
<a href="#" onclick="shrinkHeader(!current_header); return false;"><img id="upshrink" src="'
$settings['images_url'], '/', empty($options['collapse_header']) ? 'upshrink.gif' 'upshrink2.gif''" alt="*" title="'$txt['upshrink_description'], '" align="bottom" style="margin: 0 1ex;" /></a>
</td>
</tr>
<tr id="upshrinkHeader"'
, empty($options['collapse_header']) ? '' ' style="display: none;"''>
<td valign="top" colspan="2">
<table width="100%" class="bordercolor" cellpadding="8" cellspacing="1" border="0" style="margin-top: 1px;">
<tr>'
;

if (!empty($context['user']['avatar']))
echo '
<td class="windowbg" valign="middle">'
$context['user']['avatar']['image'], '</td>';

echo '
<td colspan="2" width="100%" valign="top" class="windowbg2"><span class="middletext">'
;

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
echo '
<a href="'
$scripturl'?action=unread">'$txt['unread_since_visit'], '</a> <br />
<a href="'
$scripturl'?action=unreadreplies">'$txt['show_unread_replies'], '</a><br />';

}
// Otherwise they're a guest - send them a lovely greeting...
else
echo $txt['welcome_guest'];

// Now, onto our second set of info, are they logged in again?
if ($context['user']['is_logged'])
{
// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<b>'
$txt[616], '</b><br />';

// Are there any members waiting for approval?
if (!empty($context['unapproved_members']))
echo '
'
$context['unapproved_members'] == $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="'$scripturl'?action=viewmembers;sa=browse;type=approve">'$context['unapproved_members'] == $txt['approve_member'] : $context['unapproved_members'] . ' ' $txt['approve_members'], '</a> '$txt['approve_members_waiting'], '<br />';

// Show the total time logged in?
if (!empty($context['user']['total_time_logged_in']))
{
echo '
'
$txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br />';
}
echo ' </span>';
}
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
else
{
echo ' </span>
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/sha1.js"></script>

<form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" class="middletext" style="margin: 3px 1ex 1px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' $context['session_id'] . '\');"' '''>
<input type="text" name="user" size="10" /> <input type="password" name="passwrd" size="10" />
<select name="cookielength">
<option value="60">'
$txt['smf53'], '</option>
<option value="1440">'
$txt['smf47'], '</option>
<option value="10080">'
$txt['smf48'], '</option>
<option value="43200">'
$txt['smf49'], '</option>
<option value="-1" selected="selected">'
$txt['smf50'], '</option>
</select>
<input type="submit" value="'
$txt[34], '" /><br />
<span class="middletext">'
$txt['smf52'], '</span>
<input type="hidden" name="hash_passwrd" value="" />
</form>'
;
}

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

echo '
<table id="upshrinkHeader2"'
, empty($options['collapse_header']) ? '' ' style="display: none;"'' width="100%" cellpadding="4" cellspacing="0" border="0">
<tr>'
;

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">
<span class="smalltext"><b>'
$txt[102], '</b>: '$context['random_news_line'], '</span>
</td>'
;
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">
<form action="'
$scripturl'?action=search2" method="post" accept-charset="'$context['character_set'], '" style="margin: 0;">
<a href="'
$scripturl'?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />&nbsp;
<input type="submit" name="submit" value="'
$txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />'
;

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="'
$context['current_topic'], '" />';

// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd['
$context['current_board'], ']" value="'$context['current_board'], '" />';

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


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


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

function 
template_main_below()
{
global $context$settings$options$scripturl$txt;

echo '
</div>'
;

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
echo '

<div id="footerarea" style="text-align: center; padding-bottom: 1ex;'
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? ' width: 100%;' '''">
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function smfFooterHighlight(element, value)
{
element.src = smf_images_url + "/" + (value ? "h_" : "") + element.id + ".gif";
}
// ]]></script>
<table cellspacing="0" cellpadding="3" border="0" align="center" width="100%">
<tr>
<td width="28%" valign="middle" align="'
, !$context['right_to_left'] ? 'right' 'left''">
<a href="http://www.mysql.com/" target="_blank"><img id="powered-mysql" src="'
$settings['images_url'], '/powered-mysql.gif" alt="'$txt['powered_by_mysql'], '" width="54" height="20" style="margin: 5px 16px;" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
<a href="http://www.php.net/" target="_blank"><img id="powered-php" src="'
$settings['images_url'], '/powered-php.gif" alt="'$txt['powered_by_php'], '" width="54" height="20" style="margin: 5px 16px;" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
</td>
<td valign="middle" align="center" style="white-space: nowrap;">
'
theme_copyright(), '
</td>
<td width="28%" valign="middle" align="'
, !$context['right_to_left'] ? 'left' 'right''">
<a href="http://validator.w3.org/check/referer" target="_blank"><img id="valid-xhtml10" src="'
$settings['images_url'], '/valid-xhtml10.gif" alt="'$txt['valid_xhtml'], '" width="54" height="20" style="margin: 5px 16px;" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
<a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank"><img id="valid-css" src="'
$settings['images_url'], '/valid-css.gif" alt="'$txt['valid_css'], '" width="54" height="20" style="margin: 5px 16px;" onmouseover="smfFooterHighlight(this, true);" onmouseout="smfFooterHighlight(this, false);" /></a>
</td>
</tr>
</table>'
;

// Show the load time?
if ($context['show_load_time'])
echo '
<span class="smalltext">'
$txt['smf301'], $context['load_time'], $txt['smf302'], $context['load_queries'], $txt['smf302b'], '</span>';

// This is an interesting bug in Internet Explorer AND Safari. Rather annoying, it makes overflows just not tall enough.
if (($context['browser']['is_ie'] && !$context['browser']['is_ie4']) || $context['browser']['is_mac_ie'] || $context['browser']['is_safari'] || $context['browser']['is_firefox'])
{
// The purpose of this code is to fix the height of overflow: auto div blocks, because IE can't figure it out for itself.
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA['
;

// Unfortunately, Safari does not have a "getComputedStyle" implementation yet, so we have to just do it to code...
if ($context['browser']['is_safari'])
echo '
window.addEventListener("load", smf_codeFix, false);

function smf_codeFix()
{
var codeFix = document.getElementsByTagName ? document.getElementsByTagName("div") : document.all.tags("div");

for (var i = 0; i < codeFix.length; i++)
{
if ((codeFix[i].className == "code" || codeFix[i].className == "post" || codeFix[i].className == "signature") && codeFix[i].offsetHeight < 20)
codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + "px";
}
}'
;
elseif ($context['browser']['is_firefox'])
echo '
window.addEventListener("load", smf_codeFix, false);
function smf_codeFix()
{
var codeFix = document.getElementsByTagName ? document.getElementsByTagName("div") : document.all.tags("div");

for (var i = 0; i < codeFix.length; i++)
{
if (codeFix[i].className == "code" && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0))
codeFix[i].style.overflow = "scroll";
}
}'
;
else
echo '
var window_oldOnload = window.onload;
window.onload = smf_codeFix;

function smf_codeFix()
{
var codeFix = document.getElementsByTagName ? document.getElementsByTagName("div") : document.all.tags("div");

for (var i = codeFix.length - 1; i > 0; i--)
{
if (codeFix[i].currentStyle.overflow == "auto" && (codeFix[i].currentStyle.height == "" || codeFix[i].currentStyle.height == "auto") && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0) && (codeFix[i].offsetHeight != 0 || codeFix[i].className == "code"))
codeFix[i].style.height = (codeFix[i].offsetHeight + 36) + "px";
}

if (window_oldOnload)
{
window_oldOnload();
window_oldOnload = null;
}
}'
;

echo '
// ]]></script>'
;
}

echo '
</div>'
;

// The following will be used to let the user know that some AJAX process is running
echo '
<div id="ajax_in_progress" style="display: none;'
$context['browser']['is_ie'] && !$context['browser']['is_ie7'] ? 'position: absolute;' '''">'$txt['ajax_in_progress'], '</div>
</body></html>'
;
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree()
{
global $context$settings$options;

echo '<div class="nav" style="font-size: smaller; margin-bottom: 2ex; margin-top: 2ex;">';

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Show the link, including a URL if it should have one.
echo '<b>'$settings['linktree_link'] && isset($tree['url']) ? '<a href="' $tree['url'] . '" class="nav">' $tree['name'] . '</a>' $tree['name'], '</b>';

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo '&nbsp;>&nbsp;';
}

echo '</div>';
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context$settings$options$scripturl$txt;

// Work out where we currently are.
$current_action 'home';
if (in_array($context['current_action'], array('admin''ban''boardrecount''cleanperms''detailedversion''dumpdb''featuresettings''featuresettings2''findmember''maintain''manageattachments''manageboards''managecalendar''managesearch''membergroups''modlog''news''optimizetables''packageget''packages''permissions''pgdownload''postsettings''regcenter''repairboards''reports''serversettings''serversettings2''smileys''viewErrorLog''viewmembers')))
$current_action 'admin';
if (in_array($context['current_action'], array('search''admin''calendar''profile''mlist''register''login''help''pm')))
$current_action $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action 'search';
if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' 'profile' 'admin';

// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first 'last';
$last 'first';
}
else
{
$first 'first';
$last 'last';
}

// Show the start of the tab section.
echo '
<table cellpadding="0" cellspacing="0" border="0" style="margin-left: 10px;">
<tr>
<td class="maintab_' 
$first '">&nbsp;</td>';

// Show the [home] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'home' 'active_back' 'back' '">
<a href="'
$scripturl'">' $txt[103] , '</a>
</td>' 
$current_action == 'home' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// Show the [help] button.
echo ($current_action == 'help' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'help' 'active_back' 'back' '">
<a href="'
$scripturl'?action=help">' $txt[119] , '</a>
</td>' 
$current_action == 'help' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// How about the [search] button?
if ($context['allow_search'])
echo ($current_action == 'search' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'search' 'active_back' 'back' '">
<a href="'
$scripturl'?action=search">' $txt[182] , '</a>
</td>' 
$current_action == 'search' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action == 'admin' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'admin' 'active_back' 'back' '">
<a href="'
$scripturl'?action=admin">' $txt[2] , '</a>
</td>' 
$current_action == 'admin' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo ($current_action == 'profile' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'profile' 'active_back' 'back' '">
<a href="'
$scripturl'?action=profile">' $txt[79] , '</a>
</td>' 
$current_action == 'profile' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'pm' 'active_back' 'back' '">
<a href="'
$scripturl'?action=pm">' $txt['pm_short'] , ' '$context['user']['unread_messages'] > '[<strong>'$context['user']['unread_messages'] . '</strong>]' '' '</a>
</td>' 
$current_action == 'pm' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// The [calendar]!
if ($context['allow_calendar'])
echo ($current_action == 'calendar' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'calendar' 'active_back' 'back' '">
<a href="'
$scripturl'?action=calendar">' $txt['calendar24'] , '</a>
</td>' 
$current_action == 'calendar' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// the [member] list button
if ($context['allow_memberlist'])
echo ($current_action == 'mlist' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'mlist' 'active_back' 'back' '">
<a href="'
$scripturl'?action=mlist">' $txt[331] , '</a>
</td>' 
$current_action == 'mlist' '<td class="maintab_active_' $last '">&nbsp;</td>' '';


// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'login' 'active_back' 'back' '">
<a href="'
$scripturl'?action=login">' $txt[34] , '</a>
</td>' 
$current_action == 'login' '<td class="maintab_active_' $last '">&nbsp;</td>' '';


// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'register' 'active_back' 'back' '">
<a href="'
$scripturl'?action=register">' $txt[97] , '</a>
</td>' 
$current_action == 'register' '<td class="maintab_active_' $last '">&nbsp;</td>' '';


// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
<td valign="top" class="maintab_' 
$current_action == 'logout' 'active_back' 'back' '">
<a href="'
$scripturl'?action=logout;sesc='$context['session_id'], '">' $txt[108] , '</a>
</td>' 
$current_action == 'logout' '<td class="maintab_active_' $last '">&nbsp;</td>' '';

// The end of tab section.
echo '
<td class="maintab_' 
$last '">&nbsp;</td>
</tr>
</table>'
;

}











// Generate a strip of buttons.
function template_button_strip($button_strip$direction 'top'$force_reset false$custom_td '')
{
global $settings$buttons$context$txt$scripturl;

// Create the buttons...
foreach ($button_strip as $key => $value)
{
if (isset($value['test']) && empty($context[$value['test']]))
{
unset($button_strip[$key]);
continue;
}
elseif (!isset($buttons[$key]) || $force_reset)
$buttons[$key] = '<a href="' $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' $txt[$value['text']] . '</a>';

$button_strip[$key] = $buttons[$key];
}

if (empty($button_strip))
return '<td>&nbsp;</td>';

echo '
<td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'last' 'first' '">&nbsp;</td>
<td class="'
$direction == 'top' 'main' 'mirror''tab_back">'implode(' &nbsp;|&nbsp; '$button_strip) , '</td>
<td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'first' 'last' '">&nbsp;</td>';
}

?>


Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: bindasboy on April 26, 2009, 02:20:56 AM
hey also tell how to add ads on wap2 version of smf ....

Thanks for the above Info but i use ad magement mod for that.... i want to know how to add ads on wap version... plz help...

Thanks
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: vegetablegod on April 27, 2009, 12:14:06 AM
Hey JBlaze, I just curious as to the status of this. thanks!
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: JBlaze on April 27, 2009, 12:24:17 AM
Quote from: vegetablegod on April 27, 2009, 12:14:06 AM
Hey JBlaze, I just curious as to the status of this. thanks!

Sorry, I haven't been able to get around to it. I'm just loading it up now :)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: bindasboy on April 27, 2009, 03:02:01 AM
i am working on it and i have got little success in it.... as soon as i complete it i will post it....... :D
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: vegetablegod on April 28, 2009, 08:51:30 AM
Thanks for the help but I figured it how to do it on my own.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: ellion on May 16, 2009, 05:55:17 AM
hi, thanks for all the advice about displaying ads.

does any body here know of a way that i could supress adds on the non topic pages including board index?

i would like to be able to do this due to the high ad impressions on board index and low ctr. plus non topic pages generally show ads that are irrelavant which makes the forum look lame.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: ScottDB on July 15, 2009, 01:58:54 AM
Would really like to use this in my themes. I'm kind of a newbie and would like to know where to add the adsense ID in the 3rd choice for adds after the first post.

Also I just tried adding this to Classic YaBB SE Theme. I copied the code and placed it after the first </table> inside a <table></table>. Not sure if this is what I was supposed to do
I can't get it to work. Can someone help a newbie out?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: snyperthugs on April 24, 2010, 06:53:19 PM
I can not get adsense to show up after the first post. I have tried everything, I have no idea why its not working. I am using version 1.1.11 with Theme Ferry Tema. Any help is greatly apreciated
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: upperclass09 on April 29, 2010, 10:07:25 PM
Kinda interesting info to share.

Adsense TOS says you can't put ads in pages that are exclusively asking input from the user, which means in vBulletin creating a thread page, replying or editing a post.

This code will put your ads between the navbar and forum/thread listing. Edit your "navbar" template, and after
Title: Re: Forum advice :: How I placed Adsense ads Inside First Post
Post by: netjockey on June 14, 2010, 06:05:08 AM
 How Can I placed Adsense ads Inside First Post

Hello, i want to placed the ads inside the first post, not after the first post(this can be easily achived using the admod)

but how to make the ads appear inside the first post, i mean next to the content of first post
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on June 14, 2010, 12:50:19 PM
Quote from: netjockey on June 14, 2010, 06:05:08 AM
How Can I placed Adsense ads Inside First Post

Hello, i want to placed the ads inside the first post, not after the first post(this can be easily achived using the admod)

but how to make the ads appear inside the first post, i mean next to the content of first post
If you really wanna do it, look at display.template.php. Make a line of code like, if this is the first post, echo bla bla bla... Put it where the post should appear. May be at the moderator or ip line or above signature. That should work.

NB: By the way, dont ask me about the code as I am not a coder. This is just an idea if it helps. :)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: netjockey on June 16, 2010, 10:30:07 AM
ya i know that, but need a example and a bit more help to do it
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on June 16, 2010, 02:46:18 PM
Quote from: netjockey on June 14, 2010, 06:05:08 AM
How Can I placed Adsense ads Inside First Post

Hello, i want to placed the ads inside the first post, not after the first post(this can be easily achived using the admod)

but how to make the ads appear inside the first post, i mean next to the content of first post
Please backup the file before you modify it.
Open display.template.php.
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '><div style="float:left; width:260px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-8080820489600551";
/* All 250x250 */
google_ad_slot = "8967115259";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>', $message['body'], '</div>
</div>';

Edited. Tested. Ok! (Please refer correction below)
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg181.imageshack.us%2Fimg181%2F7449%2Fpicvt3.th.jpg&hash=a0e7da606bbf1abc25ce109a12b2b99bbb348afc)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on June 17, 2010, 09:28:46 AM
After some reference, I clean up the code a bit with ad only in the first post. Change float:left; width:270px; and adsense id to your need.
Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="float:left; width:270px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 250x250 */
google_ad_slot = "8967115259";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: adean on July 12, 2010, 10:13:52 PM
Is this code still applicable to SMF 1.1.11

Quote from: nite0859 on February 25, 2007, 09:47:21 PM
DEMO :: http://forum.midessa.net
Edit: 06-18-2007: I am re-installing my forum.

[Note]
I'm not "supporting" this modification. I got some help over at Webmasterstalks (http://www.webmasterstalks.com/general/adsense-at-the-bottom-of-the-first-post-t1071.0.html). Backup your files before you modify them. Please update this code with your adsense ID. Show your love for this modification by promoting The Simple Machines Forum Directory (http://www.smfoogle.com) on your website. All I did was put adsense inside its own <table> after I saw a </table> in the files that I modified.
[/note]

index.template.php -- Puts adsense on every page; useful if you use Tinyportal left and right blocks..


// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

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

// Begin Adsense on Index.
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;" class="windowbg">
<tr>
<td valign="top" width="85%" height="100%">
<div style="overflow: auto; width: 100%;" align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-728x90
google_ad_channel = "8891092745";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
';

// End of Adsense on Index.


BoardIndex.template.php -- Puts adsense on Board Index, before Info Center.

// Show the mark all as read button?
if ($settings['show_mark_read'] && !empty($context['categories']))
echo '
<table cellpadding="0" cellspacing="0" border="0" style="position: relative; top: -5px;">
<tr>
', template_button_strip($mark_read_button, 'top'), '
</tr>
</table>';
echo '
</td>
</tr>
</table>';
}

// Adsense before info center.
    echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
                        <td valign="top" width="85%" height="100%" class="windowbg2">
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al";
//2007-02-18: midessa-forum-468x15
google_ad_channel = "8866871717";
google_color_border = "423935";
google_color_bg = "423935";
google_color_link = "D0D0D0";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
<td valign="top" width="85%" height="100%" class="windowbg">
<br />
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<br />
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-468x60
google_ad_channel = "8764535480";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br><br />
</div>
<br />
</td>
</tr>
</table>';
// End Adsense before info center.

// Here's where the "Info Center" starts...
echo '<br />
<div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
<div class="catbg" style="padding: 6px; vertical-align: middle; text-align: center; ">
<a href="#" onclick="shrinkHeaderIC(!current_header_ic); return false;"><img id="upshrink_ic" src="', $settings['images_url'], '/', empty($options['collapse_header_ic']) ? 'collapse.gif' : 'expand.gif', '" alt="*" title="', $txt['upshrink_description'], '" style="margin-right: 2ex;" align="right" /></a>
', $txt[685], '
</div>
<div id="upshrinkHeaderIC"', empty($options['collapse_header_ic']) ? '' : ' style="display: none;"', '>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';


Display.template.php -- Puts adsense after EVERY first post.

// 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>';

// Adsense after first post.
if ($message['id'] == $context['first_message'])
{
    echo '
        <tr>
<td style="padding: 0px 1px 0 1px;">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
                        <td valign="top" width="85%" height="100%" class="windowbg2">
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al";
//2007-02-18: midessa-forum-468x15
google_ad_channel = "8866871717";
google_color_border = "423935";
google_color_bg = "423935";
google_color_link = "D0D0D0";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
                    <tr>
<td valign="top" width="85%" height="100%" class="windowbg">
<br />
<div style="overflow: auto; width: 100%;" align="center" class="windowbg">
<script type="text/javascript"><!--
google_ad_client = "pub-";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-02-18: midessa-forum-468x60
google_ad_channel = "8764535480";
google_color_border = "2B2B30";
google_color_bg = "2B2B30";
google_color_link = "FFFFFF";
google_color_text = "D0D0D0";
google_color_url = "F7DDAA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br><br/>
</div>
<br />
</td>
</tr>
</table>
</td>
</tr>';
}
// End Adsense after first post.



Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: donjazzy on December 24, 2010, 01:54:16 AM
Quote from: ahrasis on June 17, 2010, 09:28:46 AM
After some reference, I clean up the code a bit with ad only in the first post. Change float:left; width:270px; and adsense id to your need.
Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="float:left; width:270px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 250x250 */
google_ad_slot = "8967115259";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

At Abrahsis please how can I place 728/90 on top of the first post right below this line below, that is the horizontal line

Re: Forum advice :: How I placed Adsense on my forum.
« Reply #60 on: February 21, 2009, 11:36:27 AM »
--------------------------------------------------------------------------------------------------------------------------


thanks

Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on December 24, 2010, 10:39:16 PM
Please provide your Display.template.php file.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on December 30, 2010, 05:47:37 AM
Just change my code above a bit like this. Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="text-align:center;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 790x90 */
google_ad_slot = "xxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

Note that the float has the effect of floating the ads inside the post but align will put it outside the post (in this case above the post and centered).
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: donjazzy on December 30, 2010, 08:04:21 AM
@ Abrahsis you are just too much for this community. It works like magic. Cuddles  :) Sir.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Sandra Khairul Riz on January 04, 2011, 07:52:13 AM
Quote from: ahrasis on June 17, 2010, 09:28:46 AM
After some reference, I clean up the code a bit with ad only in the first post. Change float:left; width:270px; and adsense id to your need.
Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="float:left; width:270px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 250x250 */
google_ad_slot = "8967115259";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

I use the code on 2.0 rc3 and it parse error.

Please how can I place 336/280 next to the content of every last post on the left as explained above. Please I want it to be appearing at every last post alone.

NOTE: only last post I want it to be appearing (PLACE NEXT TO THE CONTENT ON LEFT SIDE, as seen in your example above) Thanks in advance
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on January 04, 2011, 09:55:20 AM
You can try this tips and tricks.

Firstly, do this:
Quote from: Kays on October 02, 2010, 12:44:24 AM
In Display.php look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then, open Display.template.php and find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if($message['is_last'])
echo '
<div style="float:left; width:346px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 336x280 */
google_ad_slot = "xxxxxxxxxxxxxx";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';


Have fun!
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Sandra Khairul Riz on January 06, 2011, 08:46:20 AM
Yes I will have fun indeed. It works without stress. Thanks
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on January 06, 2011, 09:48:47 AM
Nice to hear it works for you.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: harleystreet on January 10, 2011, 04:21:48 AM
Hi
Thanks for the adsense code, doesn't matter who coded it, it's all about sharing, I will credit both of you if I get asked.

Thanks again
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: donjazzy on January 10, 2011, 08:19:37 AM
Quote from: ahrasis on January 04, 2011, 09:55:20 AM
You can try this tips and tricks.

Firstly, do this:
Quote from: Kays on October 02, 2010, 12:44:24 AM
In Display.php look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then, open Display.template.php and find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if($message['is_last'])
echo '
<div style="float:left; width:346px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 336x280 */
google_ad_slot = "xxxxxxxxxxxxxx";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';


Have fun!
Sorry 'counter' => $counter cannot be found in smf 2.0 rc3 or rc4,  please what is the way out as I ONLY want the 336/280 ad displaying next to the content of every last post at LEFT SIDE.  Thanks.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on January 13, 2011, 06:16:19 AM
Please look again. In the first part, you need to find counter and add after it in Display.php (Source folder) and not Display.template.php (Theme folder). This has been confirmed by other users and the mod goes perfectly well.

Only then you made changes in Display.template.php for the second part.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Sandra Khairul Riz on January 17, 2011, 09:19:36 AM
Quote from: ahrasis on January 13, 2011, 06:16:19 AM
Please look again. In the first part, you need to find counter and add after it in Display.php (Source folder) and not Display.template.php (Theme folder). This has been confirmed by other users and the mod goes perfectly well.

Only then you made changes in Display.template.php for the second part.
I am kin to ask if it possible to place ad in first and last post. The one for  last post is working well after following your tweak above. But I love it also appears next to the content on left side of first post. How can I make this possible change please.  I have tried but could not. Thanks
Note: I want the add to display in next to content of first and last post respectively (LEFT SIDE)
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on January 18, 2011, 04:17:23 PM
You can try this tips and tricks. Firstly, do this:

In /Sources folder, open Display.php and look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then, open Display.template.php and find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Try replacing it with this:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';

if ($message['id'] == $context['first_message']) || if($message['is_last'])
echo '
<div style="float:left; width:346px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 336x280 */
google_ad_slot = "xxxxxxxxxxxxxx";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';

echo '
', $message['body'], '</div>
</div>';

Have fun and good luck!
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on January 19, 2011, 04:36:57 AM
Try changing this line:
if ($message['id'] == $context['first_message']) || if($message['is_last'])

to something like this:
if (($message['id'] == $context['first_message']) || $message['is_last'])

or to something like this (if the above still is not working because I've not tested any of these yet):
if ($message['id'] == $context['first_message'] || $message['is_last'])
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: donjazzy on January 27, 2011, 02:00:05 AM
Quote from: simply nobody on December 30, 2010, 05:47:37 AM
Just change my code above a bit like this. Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="text-align:center;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 790x90 */
google_ad_slot = "xxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

Note that the float has the effect of floating the ads inside the post but align will put it outside the post (in this case above the post and centered).
You know  I requested this and you did it, BUT I have a problem. When I tried to place an ad to be appearing next to the content (LEFT SIDE) of every last post, I could not because when I do, this code will be gone. I still want this ad appearing as-is WHILE a 336/280 will be appearing next to the content at every last post. Please what is the tips and trick to this. Thanks Sir   
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on January 27, 2011, 05:40:23 AM
Quote from: donjazzy on January 27, 2011, 02:00:05 AM
Quote from: simply nobody on December 30, 2010, 05:47:37 AM
Just change my code above a bit like this. Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="text-align:center;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 790x90 */
google_ad_slot = "xxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

Note that the float has the effect of floating the ads inside the post but align will put it outside the post (in this case above the post and centered).
You know  I requested this and you did it, BUT I have a problem. When I tried to place an ad to be appearing next to the content (LEFT SIDE) of every last post, I could not because when I do, this code will be gone. I still want this ad appearing as-is WHILE a 336/280 will be appearing next to the content at every last post. Please what is the tips and trick to this. Thanks Sir
I have answered that. Read posts above this post, starting from your post about this earlier before.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: donjazzy on February 21, 2011, 03:37:24 AM
How can disable ads from showing in certain boards, perhaps I have a board that has sensual discussion and I will like to disable all ads from appearing there. How can I achieve this?. thanks
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: ammaar102 on February 23, 2011, 12:00:12 AM
By posting these details you have solve my problem.Great set up....I'm going to try this.. 8)



Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on February 24, 2011, 08:42:27 AM
Quote from: ammaar102 on February 23, 2011, 12:00:12 AM
By posting these details you have solve my problem.Great set up....I'm going to try this.. 8)
You are welcome. Sharing is caring. Do share if you got any ideas / tips / tricks on this or its related things.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on March 01, 2011, 12:52:49 PM
Quote from: donjazzy on February 21, 2011, 03:37:24 AM
How can disable ads from showing in certain boards, perhaps I have a board that has sensual discussion and I will like to disable all ads from appearing there. How can I achieve this?. thanks
You shoud try to use a more complex if and elseif. If only I have extra time to help.

Something like:
If the board is number 1, 2 or 3
display no ad
else display ad

Just have to translate this to a working SMF php code. Do ask in Coding or respective version of your SMF for proper support.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: InfoStrides on April 24, 2011, 02:30:36 PM
Quote from: Sandra Khairul Riz on April 24, 2011, 02:25:00 PM
Hi, how can I place ad after every first post in smf 2.0 using tips/tricks. Thanks

I would like to know if there has been any issue with the mods developed for this purpose. You can try and install Simple Ads or Ad Management Mods. I have tested them and they work fine. You can even do more customisation on Simple Ads. Check here: http://www.theinfostrides.com for how I placed my ads.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: donjazzy on April 26, 2011, 11:04:58 AM
I really like using tips and trick as oppose ad mod. Please how can I place ad after every first post in smf2.0. Thanks.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on April 26, 2011, 08:36:45 PM
Try changing the code above a bit like this. Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>
', $message['body'], '';
if ($message['id'] == $context['first_message'])
echo '
<div style="text-align:center;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 790x90 */
google_ad_slot = "xxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
</div>
</div>';
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: donjazzy on May 20, 2011, 03:49:33 AM
Works fine. Thanks
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: azzuhro on June 23, 2011, 01:36:19 AM
example_http://www.azzuhro-forum.tk

I successfully edit the theme

Display.template.php

echo '
<tr> <td style="padding: 0 0 1px 0;"> </ td> </ tr> <center> <script>
ADS HERE
</ table>
<a name="lastPost"> </ a> ';


example _http://www.azzuhro-forum.tk


index.template.php

echo '
            document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

            document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";

            current_header_ic = mode;
         }
      // ]]></script>
ADS HERE
</head>
<body>';


example _http://www.azzuhro-forum.tk
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Ventic on September 11, 2011, 11:12:31 AM
didnt work to me
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: moguns on September 15, 2011, 07:27:18 PM
Hello,

Does anyone know how to place an add between first and second post only?

Thanks
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: ayeweb on September 16, 2011, 08:45:42 AM
wow that greate sir.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Biology Forums on September 22, 2011, 09:49:36 PM
Best what to do this is to use TinyPortal mod, it's very effective.
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on September 28, 2011, 02:35:02 AM
Quote from: Ventic on September 11, 2011, 11:12:31 AM
didnt work to me
What didn't work for you? How did you do it?
Title: Re: Forum advice :: How I placed Adsense on my forum.
Post by: Hj Ahmad Rasyid Hj Ismail on September 28, 2011, 02:35:28 AM
Quote from: moguns on September 15, 2011, 07:27:18 PM
Hello,

Does anyone know how to place an add between first and second post only?

Thanks
Care to read the OP first before asking?