Advertisement:

Author Topic: [Tip] Showing ads or text inside the message without template edits  (Read 17848 times)

Offline Suki

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 15,088
  • Kaizoku Jotei
    • MissAllSunday on GitHub
    • SMF mods
This is rather a simple tip for showing ads, text, images, custom code, etc  before or after the message in  every message or just the first one,  doing it on Source means  that no matter what theme you're using, it will work on that or any other theme,  this tip can be used in either 1.1.x or 2.0.

first we open our /Sources/Display.php  and find this line

// Do the censor thang.


and above that add this:

Code: [Select]
// Let's define some parameters
// by default the ad will appear on the first page and before the message,
// you can configure the parameters on the array below

$opciones = array(
'primer_tema' => true,   // false for showing on every message, true for showing only in first message
'espacio' => '<p />',    // an space is required to properly separate the ad from the message
'antes' => true,      // true show the ad before the message,  false show it after the message
);
   
$codigo = 'your code';   // here you can write your code, remember to properly escape single quotes '  like this \' 
   
   
// We put the ad with the body together. here the ad will be before the body on first message
if ($counter == 0 && $opciones['primer_tema'] == true && $opciones['antes'] == true)
$message['body'] = ('' . $codigo . $opciones['espacio'] .$message['body']);

//   Here the ad will be showed on all messages before the body
if ($opciones['primer_tema'] == false && $opciones['antes'] == true)
$message['body'] = ('' . $codigo . $opciones['espacio'] .$message['body']);

//   Here the ad will be showed after the body on first message only
if ($counter == 0 && $opciones['primer_tema'] == true && $opciones['antes'] == false)
$message['body'] = ('' . $message['body'] . $opciones['espacio'] . $codigo);

//   Here the ad its showed after the body on all messages
if ($opciones['primer_tema'] == false && $opciones['antes'] == false)
$message['body'] = ('' . $message['body'] . $opciones['espacio'] . $codigo);



the code has comments and its pretty simple to understand:

'primer_tema' => true,     if true, the ad will appear only in the first message,   write false  if you want the add to appear on every message

'espacio' => '<p />',   a simple <p />  tag to separate the ad from the actual message.

'antes' => true,   if true, the ad will appear before the message's body,  write false  to show the ad after the message's body.


thats pretty much it!  now the ad will appear  right before or after the message's body in every theme you use.
Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,101
    • @studyforceps on Twitter
    • Study Force
Re: [Tip] Showing ads or text inside the message without template edits
« Reply #1 on: March 07, 2011, 02:08:01 PM »
Can you show us an example :)?

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,430
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: [Tip] Showing ads or text inside the message without template edits
« Reply #2 on: March 07, 2011, 02:42:40 PM »
Moved to Tips and Tricks for ya, Miss All Sunday :)

Offline Suki

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 15,088
  • Kaizoku Jotei
    • MissAllSunday on GitHub
    • SMF mods
Re: [Tip] Showing ads or text inside the message without template edits
« Reply #3 on: March 07, 2011, 02:47:51 PM »
Moved to Tips and Tricks for ya, Miss All Sunday :)

thanks ;)

Can you show us an example :)?


you mean a screen shot or a live forum example?
Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,101
    • @studyforceps on Twitter
    • Study Force
Re: [Tip] Showing ads or text inside the message without template edits
« Reply #4 on: March 07, 2011, 02:51:58 PM »
Yeah, exactly.

Offline paketdigital

  • Newbie
  • *
  • Posts: 1
Re: [Tip] Showing ads or text inside the message without template edits
« Reply #5 on: March 08, 2011, 05:54:59 AM »
How smart is that during my search. thanks a lot friend ;D


Offline Maever

  • Semi-Newbie
  • *
  • Posts: 31
  • Gender: Male
    • FreeSMF - Free Forum Hosting
Re: [Tip] Showing ads or text inside the message without template edits
« Reply #6 on: March 08, 2011, 08:05:43 AM »
Great stuff, nice tip.



Offline morean51

  • Newbie
  • *
  • Posts: 9
Re: [Tip] Showing ads or text inside the message without template edits
« Reply #7 on: March 09, 2011, 02:06:07 AM »
good tip thank you for it