News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[Tip] Showing ads or text inside the message without template edits

Started by Suki, March 07, 2011, 01:28:27 PM

Previous topic - Next topic

Suki

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:

// 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.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.


Matthew K.


Suki

Quote from: Labradoodle-360 on March 07, 2011, 02:42:40 PM
Moved to Tips and Tricks for ya, Miss All Sunday :)

thanks ;)

Quote from: shuban on March 07, 2011, 02:08:01 PM
Can you show us an example :)?


you mean a screen shot or a live forum example?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.


paketdigital




Advertisement: