News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[SMF Tip] Various Ad Placements

Started by ascaland, April 22, 2011, 11:27:52 AM

Previous topic - Next topic

ascaland

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!

kat

As this is a tip, I've moved it to...


er...


Tips!

ascaland


NanoSector

* Ad Management Mod comes to mind to simplify this...
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."


Masterd


NHWD


ascaland

Quote from: Project Evolution on April 22, 2011, 11:27:52 AM
This is just if you would like to add a quick ad or two, if you want full control and automation for ads then I suggest you use a modification.

NanoSector

Quote from: Project Evolution on April 23, 2011, 10:26:44 AM
Quote from: Project Evolution on April 22, 2011, 11:27:52 AM
This is just if you would like to add a quick ad or two, if you want full control and automation for ads then I suggest you use a modification.
Quote from: Yoshi2889 on April 22, 2011, 11:56:59 AM
* Ad Management Mod comes to mind to simplify this...

:P

That mod handles large and tiny needs for ads.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

ascaland

Quote from: Yoshi2889 on April 23, 2011, 02:12:50 PM
Quote from: Project Evolution on April 23, 2011, 10:26:44 AM
Quote from: Project Evolution on April 22, 2011, 11:27:52 AM
This is just if you would like to add a quick ad or two, if you want full control and automation for ads then I suggest you use a modification.
Quote from: Yoshi2889 on April 22, 2011, 11:56:59 AM
* Ad Management Mod comes to mind to simplify this...

:P

That mod handles large and tiny needs for ads.

Personally, I wouldnt bother with a mod if im adding an ad or two. Like what if the mod had errors anyway, you would have to fix them just to display the one or two ads you want. :p

NanoSector

Quote from: Project Evolution on April 23, 2011, 02:17:54 PM
Quote from: Yoshi2889 on April 23, 2011, 02:12:50 PM
Quote from: Project Evolution on April 23, 2011, 10:26:44 AM
Quote from: Project Evolution on April 22, 2011, 11:27:52 AM
This is just if you would like to add a quick ad or two, if you want full control and automation for ads then I suggest you use a modification.
Quote from: Yoshi2889 on April 22, 2011, 11:56:59 AM
* Ad Management Mod comes to mind to simplify this...

:P

That mod handles large and tiny needs for ads.

Personally, I wouldnt bother with a mod if im adding an ad or two. Like what if the mod had errors anyway, you would have to fix them just to display the one or two ads you want. :p
I'd rather be lazy and use that mod for it; it's not there just for the looks of it (can't say that it looks bad, however) :P
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

008Rohit

as vbgamer's Ad Management mod doesnt completely work with CORE theme I am hoping for code from you for placing ads after the last post of a topic. :)
TechTage Forum - Vintage Technology - on MDDHosting - CloudLinux & LiteSpeed Powered - MDDHosting Review

NanoSector

Quote from: 008Rohit on April 24, 2011, 10:53:35 AM
as vbgamer's Ad Management mod doesnt completely work with CORE theme I am hoping for code from you for placing ads after the last post of a topic. :)
Because Core is based from SMF 1.1.x and Curve is from 2.0...
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

ascaland

Quote from: 008Rohit on April 24, 2011, 10:53:35 AM
as vbgamer's Ad Management mod doesnt completely work with CORE theme I am hoping for code from you for placing ads after the last post of a topic. :)

If you need it somewhere and cant find it (which is most probable since I based this on SMF 2.0) I am willing to help find it for you.  ;)

Arantor

Quote from: Yoshi2889 on April 24, 2011, 11:03:14 AM
Quote from: 008Rohit on April 24, 2011, 10:53:35 AM
as vbgamer's Ad Management mod doesnt completely work with CORE theme I am hoping for code from you for placing ads after the last post of a topic. :)
Because Core is based from SMF 1.1.x and Curve is from 2.0...

It apparently doesn't work properly actually on the Core theme, either the 1.1.x or 2.0 versions... and by all accounts doesn't uninstall properly either.

Hj Ahmad Rasyid Hj Ismail

Though I like using mods, I like having a tip and trick like this, just in case I need to do things manually later on. Thanks for the tips and tricks PE.

Sandra Khairul Riz

Hi, I really like these coding tips.  Please how can I display ad after the first post in smf 2.0. Thanks

NanoSector

Quote from: Sandra Khairul Riz on April 24, 2011, 02:44:40 PM
Hi, I really like these coding tips.  Please how can I display ad after the first post in smf 2.0. Thanks
With Ad Management Mod. And in this topic if you read further then your nose is :P
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Rs Bots Pro

Quote from: Yoshi2889 on April 24, 2011, 02:45:19 PM
Quote from: Sandra Khairul Riz on April 24, 2011, 02:44:40 PM
Hi, I really like these coding tips.  Please how can I display ad after the first post in smf 2.0. Thanks
With Ad Management Mod. And in this topic if you read further then your nose is :P
none of the mods work with the majority of themes for RC4 & 5 and the ad management mod doesnt work with the default theme curve on RC5 =/ =[

skotinos

Quote from: Rs Bots Pro on April 26, 2011, 05:21:20 PM
Quote from: Yoshi2889 on April 24, 2011, 02:45:19 PM
Quote from: Sandra Khairul Riz on April 24, 2011, 02:44:40 PM
Hi, I really like these coding tips.  Please how can I display ad after the first post in smf 2.0. Thanks
With Ad Management Mod. And in this topic if you read further then your nose is :P
none of the mods work with the majority of themes for RC4 & 5 and the ad management mod doesnt work with the default theme curve on RC5 =/ =[

yes, really do not work

Advertisement: