Advertisement:

Author Topic: [SMF Tip] Various Ad Placements  (Read 41568 times)

Offline Anthony`

  • Sophist Member
  • *****
  • Posts: 1,347
  • Gender: Male
  • Formerly Project Evolution
    • AnthonyCalandra on GitHub
[SMF Tip] Various Ad Placements
« on: April 22, 2011, 11:27:52 AM »
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,
Code: [Select]
// 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,
Code: [Select]
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,
Code: [Select]
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,
Code: [Select]
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,
Code: [Select]
  echo '
        <div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
       </div>';

Replace that with,
Code: [Select]
  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,
Code: [Select]
$message['counter'] == 0 ?To,
Code: [Select]
$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,
Code: [Select]
<div style="text-align: left;">To,
Code: [Select]
<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

  • Guest
Re: [SMF Tip] Various Ad Placements
« Reply #1 on: April 22, 2011, 11:54:46 AM »
As this is a tip, I've moved it to...


er...


Tips!

Offline Anthony`

  • Sophist Member
  • *****
  • Posts: 1,347
  • Gender: Male
  • Formerly Project Evolution
    • AnthonyCalandra on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #2 on: April 22, 2011, 11:55:50 AM »
As this is a tip, I've moved it to...


er...


Tips!

Woohoo!  O:)

Offline NanoSector

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,500
  • Gender: Male
  • VC321xb47@aperture:~#
    • Yoshi2889 on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #3 on: April 22, 2011, 11:56:59 AM »
* 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."

kat

  • Guest

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,921
  • Gender: Male
Re: [SMF Tip] Various Ad Placements
« Reply #5 on: April 22, 2011, 03:31:41 PM »
This is a really nice tip. :D

Offline NHWD

  • Jr. Member
  • **
  • Posts: 304
Re: [SMF Tip] Various Ad Placements
« Reply #6 on: April 23, 2011, 02:19:00 AM »
* Ad Management Mod comes to mind to simplify this...

Offline Anthony`

  • Sophist Member
  • *****
  • Posts: 1,347
  • Gender: Male
  • Formerly Project Evolution
    • AnthonyCalandra on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #7 on: April 23, 2011, 10:26:44 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.

Offline NanoSector

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,500
  • Gender: Male
  • VC321xb47@aperture:~#
    • Yoshi2889 on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #8 on: April 23, 2011, 02:12:50 PM »
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.
* 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."

Offline Anthony`

  • Sophist Member
  • *****
  • Posts: 1,347
  • Gender: Male
  • Formerly Project Evolution
    • AnthonyCalandra on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #9 on: April 23, 2011, 02:17:54 PM »
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.
* 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

Offline NanoSector

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,500
  • Gender: Male
  • VC321xb47@aperture:~#
    • Yoshi2889 on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #10 on: April 23, 2011, 02:19:05 PM »
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.
* 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."

Offline 008Rohit

  • Semi-Newbie
  • *
  • Posts: 84
  • Gender: Male
    • TechTage
Re: [SMF Tip] Various Ad Placements
« Reply #11 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. :)
TechTage Forum - Vintage Technology - on MDDHosting - CloudLinux & LiteSpeed Powered - MDDHosting Review

Offline NanoSector

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,500
  • Gender: Male
  • VC321xb47@aperture:~#
    • Yoshi2889 on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #12 on: April 24, 2011, 11:03:14 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."

Offline Anthony`

  • Sophist Member
  • *****
  • Posts: 1,347
  • Gender: Male
  • Formerly Project Evolution
    • AnthonyCalandra on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #13 on: April 24, 2011, 11:16:41 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.  ;)

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #14 on: April 24, 2011, 11:27:27 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,916
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: [SMF Tip] Various Ad Placements
« Reply #15 on: April 24, 2011, 11:28:19 AM »
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.

Offline Sandra Khairul Riz

  • Newbie
  • *
  • Posts: 5
Re: [SMF Tip] Various Ad Placements
« Reply #16 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

Offline NanoSector

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,500
  • Gender: Male
  • VC321xb47@aperture:~#
    • Yoshi2889 on GitHub
Re: [SMF Tip] Various Ad Placements
« Reply #17 on: April 24, 2011, 02:45:19 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."

Offline Rs Bots Pro

  • Semi-Newbie
  • *
  • Posts: 61
Re: [SMF Tip] Various Ad Placements
« Reply #18 on: April 26, 2011, 05:21:20 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 =/ =[

Offline skotinos

  • Semi-Newbie
  • *
  • Posts: 16
Re: [SMF Tip] Various Ad Placements
« Reply #19 on: May 13, 2011, 10:21:14 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