Where in Display.template.php (or elsewhere) would I insert adsense code so that ads appear at the end of the first post, WITHIN the first post, as in the screen cap below, and what code would I use to precede the adsense code so that ads show up only to guests?
Thanks.
Please don't suggest the ad management mod. It does not address this.
on your display.template find this:
<div class="post"', $message['can_modify'] ? ' id="msg_' . $message['id'] . '"' : '', '>', $message['body'], '</div>
and replace with this:
<div class="post"', $message['can_modify'] ? ' id="msg_' . $message['id'] . '"' : '', '>', $message['body'], '';
if ($message['counter'] == 0 && $context['user']['is_guest'])
echo 'your ads here';
echo '</div>';
change the "your ads here" eith the adsense code, remember, simple commas ' within the echo needs to be escape with \ like this \'
Did exactly as you said, and the forum blew up. Restored from backup. Any ideas?
why will blow up? the most you can have was a syntax error easily fixed but thats all.
can you please attach your display.template of the theme your currently using
Yes, here it is.
can you also provide your adsense code or your ads code so I can put in there too ;)
Sure, here it is:
<script type="text/javascript"><!--
google_ad_client = "pub-0000000000000000";
/* 250x250, created 7/3/10 */
google_ad_slot = "4655500000";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
ok, use this, if for some reason your forum mark an error, you don't have to restore your hole site again, just tell me and I will check on it.
Thanks, but this breaks the forum. Error message upon viewing thread:
Lainaus käyttäjältä: jdougher - heinäkuu 16, 2010, 02:34:43 IP
Thanks, but this breaks the forum. Error message upon viewing thread:
Change:
echo '</div>';
, $message['can_modify'] ? 'to:
echo '</div>', $message['can_modify'] ? '
Just an update to this for SMF 2.0.....
SMF 2.0 uses a var named $is_first_post to make it easy to determine if you're in the first post in a topic. To add Adsense or other ad code to the bottom of the first post, this should work.
In Display.template.php, search for this code:
// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
echo '
<div class="signature" id="msg_', $message['id'], '_signature">', $message['member']['signature'], '</div>';
echo '
</div>
</div>
</div>';
}
Replace it with this code:
// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
echo '
<div class="signature" id="msg_', $message['id'], '_signature">', $message['member']['signature'], '</div>';
echo '
</div>';
if ($is_first_post == 1){
echo '...your Adsense code...';
}
echo '
</div>
</div>';
}
Hope this helps someone!