News:

Wondering if this will always be free?  See why free is better.

Main Menu

Forum advice :: How I placed Adsense on my forum.

Started by Niteblade, February 25, 2007, 09:47:21 PM

Previous topic - Next topic

Hj Ahmad Rasyid Hj Ismail


Hj Ahmad Rasyid Hj Ismail

Just change my code above a bit like this. Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="text-align:center;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 790x90 */
google_ad_slot = "xxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

Note that the float has the effect of floating the ads inside the post but align will put it outside the post (in this case above the post and centered).

donjazzy

@ Abrahsis you are just too much for this community. It works like magic. Cuddles  :) Sir.

Sandra Khairul Riz

Quote from: ahrasis on June 17, 2010, 09:28:46 AM
After some reference, I clean up the code a bit with ad only in the first post. Change float:left; width:270px; and adsense id to your need.
Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="float:left; width:270px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 250x250 */
google_ad_slot = "8967115259";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

I use the code on 2.0 rc3 and it parse error.

Please how can I place 336/280 next to the content of every last post on the left as explained above. Please I want it to be appearing at every last post alone.

NOTE: only last post I want it to be appearing (PLACE NEXT TO THE CONTENT ON LEFT SIDE, as seen in your example above) Thanks in advance

Hj Ahmad Rasyid Hj Ismail

You can try this tips and tricks.

Firstly, do this:
Quote from: Kays on October 02, 2010, 12:44:24 AM
In Display.php look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then, open Display.template.php and find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if($message['is_last'])
echo '
<div style="float:left; width:346px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 336x280 */
google_ad_slot = "xxxxxxxxxxxxxx";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';


Have fun!

Sandra Khairul Riz

#85
Yes I will have fun indeed. It works without stress. Thanks

Hj Ahmad Rasyid Hj Ismail


harleystreet

Hi
Thanks for the adsense code, doesn't matter who coded it, it's all about sharing, I will credit both of you if I get asked.

Thanks again

donjazzy

Quote from: ahrasis on January 04, 2011, 09:55:20 AM
You can try this tips and tricks.

Firstly, do this:
Quote from: Kays on October 02, 2010, 12:44:24 AM
In Display.php look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then, open Display.template.php and find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if($message['is_last'])
echo '
<div style="float:left; width:346px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 336x280 */
google_ad_slot = "xxxxxxxxxxxxxx";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';


Have fun!
Sorry 'counter' => $counter cannot be found in smf 2.0 rc3 or rc4,  please what is the way out as I ONLY want the 336/280 ad displaying next to the content of every last post at LEFT SIDE.  Thanks.

Hj Ahmad Rasyid Hj Ismail

Please look again. In the first part, you need to find counter and add after it in Display.php (Source folder) and not Display.template.php (Theme folder). This has been confirmed by other users and the mod goes perfectly well.

Only then you made changes in Display.template.php for the second part.

Sandra Khairul Riz

Quote from: ahrasis on January 13, 2011, 06:16:19 AM
Please look again. In the first part, you need to find counter and add after it in Display.php (Source folder) and not Display.template.php (Theme folder). This has been confirmed by other users and the mod goes perfectly well.

Only then you made changes in Display.template.php for the second part.
I am kin to ask if it possible to place ad in first and last post. The one for  last post is working well after following your tweak above. But I love it also appears next to the content on left side of first post. How can I make this possible change please.  I have tried but could not. Thanks
Note: I want the add to display in next to content of first and last post respectively (LEFT SIDE)

Hj Ahmad Rasyid Hj Ismail

You can try this tips and tricks. Firstly, do this:

In /Sources folder, open Display.php and look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then, open Display.template.php and find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Try replacing it with this:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';

if ($message['id'] == $context['first_message']) || if($message['is_last'])
echo '
<div style="float:left; width:346px;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 336x280 */
google_ad_slot = "xxxxxxxxxxxxxx";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';

echo '
', $message['body'], '</div>
</div>';

Have fun and good luck!

Hj Ahmad Rasyid Hj Ismail

Try changing this line:
if ($message['id'] == $context['first_message']) || if($message['is_last'])

to something like this:
if (($message['id'] == $context['first_message']) || $message['is_last'])

or to something like this (if the above still is not working because I've not tested any of these yet):
if ($message['id'] == $context['first_message'] || $message['is_last'])

donjazzy

Quote from: simply nobody on December 30, 2010, 05:47:37 AM
Just change my code above a bit like this. Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="text-align:center;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 790x90 */
google_ad_slot = "xxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

Note that the float has the effect of floating the ads inside the post but align will put it outside the post (in this case above the post and centered).
You know  I requested this and you did it, BUT I have a problem. When I tried to place an ad to be appearing next to the content (LEFT SIDE) of every last post, I could not because when I do, this code will be gone. I still want this ad appearing as-is WHILE a 336/280 will be appearing next to the content at every last post. Please what is the tips and trick to this. Thanks Sir   

Hj Ahmad Rasyid Hj Ismail

Quote from: donjazzy on January 27, 2011, 02:00:05 AM
Quote from: simply nobody on December 30, 2010, 05:47:37 AM
Just change my code above a bit like this. Find:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
</div>';

Replace:
echo '
<div class="inner" id="msg_', $message['id'], '"', '>';
if ($message['id'] == $context['first_message'])
echo '
<div style="text-align:center;">
<script target="_blank" type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
/* All 790x90 */
google_ad_slot = "xxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js?target=_blank">
</script></div>';
echo '
', $message['body'], '</div>
</div>';

Note that the float has the effect of floating the ads inside the post but align will put it outside the post (in this case above the post and centered).
You know  I requested this and you did it, BUT I have a problem. When I tried to place an ad to be appearing next to the content (LEFT SIDE) of every last post, I could not because when I do, this code will be gone. I still want this ad appearing as-is WHILE a 336/280 will be appearing next to the content at every last post. Please what is the tips and trick to this. Thanks Sir
I have answered that. Read posts above this post, starting from your post about this earlier before.

donjazzy

How can disable ads from showing in certain boards, perhaps I have a board that has sensual discussion and I will like to disable all ads from appearing there. How can I achieve this?. thanks

ammaar102

By posting these details you have solve my problem.Great set up....I'm going to try this.. 8)




Hj Ahmad Rasyid Hj Ismail

Quote from: ammaar102 on February 23, 2011, 12:00:12 AM
By posting these details you have solve my problem.Great set up....I'm going to try this.. 8)
You are welcome. Sharing is caring. Do share if you got any ideas / tips / tricks on this or its related things.

Hj Ahmad Rasyid Hj Ismail

Quote from: donjazzy on February 21, 2011, 03:37:24 AM
How can disable ads from showing in certain boards, perhaps I have a board that has sensual discussion and I will like to disable all ads from appearing there. How can I achieve this?. thanks
You shoud try to use a more complex if and elseif. If only I have extra time to help.

Something like:
If the board is number 1, 2 or 3
display no ad
else display ad

Just have to translate this to a working SMF php code. Do ask in Coding or respective version of your SMF for proper support.

InfoStrides

Quote from: Sandra Khairul Riz on April 24, 2011, 02:25:00 PM
Hi, how can I place ad after every first post in smf 2.0 using tips/tricks. Thanks

I would like to know if there has been any issue with the mods developed for this purpose. You can try and install Simple Ads or Ad Management Mods. I have tested them and they work fine. You can even do more customisation on Simple Ads. Check here: http://www.theinfostrides.com for how I placed my ads.

Advertisement: