This quick SMF tip will show you where you can put various ads on your page (using Google's Adsense for example) using template edits. This is just if you would like to add a quick ad or two on your pages, if you want full control and automation for ads then I suggest you use a modification. This tutorial was made for SMF 2.0.
Under the navigation menu This will display the ad right under your navigation menu. In your theme's index.template.php, find,
// Show the menu here, according to the menu sub template.
template_menu();
echo '
<br class="clear" />
</div></div>';
Above the two div tags, two new tags will be made to move the ad code down a line and a div tag with style properties to center it. Here is an example of what it should look like when done,
echo '
<br class="clear" />
<br />
<div style="text-align: center;">
PLACE YOUR AD CODE HERE
</div>
</div></div>';
Under the Who's Online From here, your ad will be displayed under the Who's Online section of your forum. In your theme's index.template.php, find, echo '
</div>
</div></div>';
// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
And replace that with,
echo '
<br />
<div style="text-align: center;">
PLACE YOUR AD CODE HERE
</div>
</div>
</div></div>';
// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
Remember to place your ad code in there.
Above the first post This will display your ad above the original poster's message in a topic. In your theme's Display.template.php, find, echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';
Replace that with,
echo '
<div class="inner" id="msg_', $message['id'], '"', '>' . ($message['counter'] == 0 ? '<div style="text-align: left;">
YOUR AD CODE HERE
</div>
<br />' : '') . '', $message['body'], '</div>
</div>';
This code determines if the message is the first one in the topic, it will display the ad above the message. If you want this to be displayed to guests only, in the above code change,
$message['counter'] == 0 ?
To,
$message['counter'] == 0 && $context['user']['is_guest'] ?
To the right of the first post This will display your ad floating to the right of the first message of the original topic. Follow the instructions above, except change,<div style="text-align: left;">
To,
<div style="float: right;">
That concludes this small SMF tip. Some mods of interest:
Global Headers and Footers - You can use this mod to display the ads only in the header and footer.
http://custom.simplemachines.org/mods/index.php?mod=351 Ad Management - Modification for displaying these ads in specified locations.
http://custom.simplemachines.org/mods/index.php?mod=255 Thanks for reading!