Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Suki in März 07, 2011, 01:28:27 NACHMITTAGS

Titel: [Tip] Showing ads or text inside the message without template edits
Beitrag von: Suki in März 07, 2011, 01:28:27 NACHMITTAGS
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.
Titel: Re: [Tip] Showing ads or text inside the message without template edits
Beitrag von: Biology Forums in März 07, 2011, 02:08:01 NACHMITTAGS
Can you show us an example :)?
Titel: Re: [Tip] Showing ads or text inside the message without template edits
Beitrag von: Matthew K. in März 07, 2011, 02:42:40 NACHMITTAGS
Moved to Tips and Tricks for ya, Miss All Sunday :)
Titel: Re: [Tip] Showing ads or text inside the message without template edits
Beitrag von: Suki in März 07, 2011, 02:47:51 NACHMITTAGS
Zitat von: Labradoodle-360 in März 07, 2011, 02:42:40 NACHMITTAGS
Moved to Tips and Tricks for ya, Miss All Sunday :)

thanks ;)

Zitat von: shuban in März 07, 2011, 02:08:01 NACHMITTAGS
Can you show us an example :)?


you mean a screen shot or a live forum example?
Titel: Re: [Tip] Showing ads or text inside the message without template edits
Beitrag von: Biology Forums in März 07, 2011, 02:51:58 NACHMITTAGS
Yeah, exactly.
Titel: Re: [Tip] Showing ads or text inside the message without template edits
Beitrag von: paketdigital in März 08, 2011, 05:54:59 VORMITTAG
How smart is that during my search. thanks a lot friend ;D

Titel: Re: [Tip] Showing ads or text inside the message without template edits
Beitrag von: Maever in März 08, 2011, 08:05:43 VORMITTAG
Great stuff, nice tip.
Titel: Re: [Tip] Showing ads or text inside the message without template edits
Beitrag von: morean51 in März 09, 2011, 02:06:07 VORMITTAG
good tip thank you for it