MyBB Community Forums

Full Version: Help! - Board Specific Code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
In my header template file.

Here's the whole thing:

<link rel="image_src"
href="http://i.imgur.com/CKoPESt.png" />
<meta property="og:image" content="http://i.imgur.com/LZhVrX2.png" />
<a name="top" id="top"></a>
<div id="header">
<div id="headformat">
<div id="branding">
<a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['logo']}" alt="{$mybb->settings['bbname']}" title="{$mybb->settings['bbname']}" /></a>
</div>
<div class="menu float_right">
<ul>
<li><a id="forumnav" href="{$mybb->settings['bburl']}/index.php">Forums</a></li>
<li><a id="forumnav" href="{$mybb->settings['bburl']}/f-Blogs">Blogs</a></li>
<li><a id="forumnav" href="{$mybb->settings['bburl']}/t-Rewards">Rewards</a></li>
</ul>
</div>

</div>

</div>

<div id="primarynav">
<div id="navformat">
{$welcomeblock}
</div>
</div>
<div id="container">

<navigation>
<br class="clear" />
{$bannedwarning}
{$bbclosedwarning}
{$unreadreports}{$unreadpmreports}{$reportedreps}
{$pending_joinrequests}
<div id="content">
<center>
<if $GLOBALS['fid'] == 52 then><else>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 2 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5089165959404876"
data-ad-slot="4447440744"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</if>
</center>
This conditional if for forumdisplay templates let me check a few things for header!
Try this instead:
<if $GLOBALS['fid'] != 52 then>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 2 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5089165959404876"
data-ad-slot="4447440744"
data-ad-format="auto"></ins>
<script type="text/javascript">
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</if>
There is no need to put it as <else>..

EDIT: ah right, $fid is defined after outputting header template. So you need a more tricky solution. Remove the conditional from header (leave only ad HTML) and put a code like this:
<if $GLOBALS['fid'] == 52 then><style type="text/css">.adsbygoogle { display: none !important;}</style></if>
just before </head> in forumdisplay, showthread, newthread, newreply and editpost templates. Tested, works.
It will probably require a plugin!

You need to create a plugin and hook it to global then use this conditional!

Since it's header then I think we should also include

THIS_SCRIPT = 'forumdisplay.php' || THIS_SCRIPT = 'showthread.php'


Maybe:
<if ($GLOBALS['fid'] == 52 && (THIS_SCRIPT = 'forumdisplay.php' || THIS_SCRIPT = 'showthread.php')) then>Adsense</if>
(2014-03-09, 05:03 PM)Destroy666 Wrote: [ -> ]Try this instead:
<if $GLOBALS['fid'] != 52 then>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 2 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5089165959404876"
data-ad-slot="4447440744"
data-ad-format="auto"></ins>
<script type="text/javascript">
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</if>
There is no need to put it as <else>..

EDIT: ah right, $fid is defined after outputting header template. So you need a more tricky solution. Remove the conditional from header (leave only ad HTML) and put a code like this:
<if $GLOBALS['fid'] == 52 then><style type="text/css">.adsbygoogle { display: none !important;}</style></if>
just before </head> in forumdisplay, showthread, newthread, newreply and editpost templates. Tested, works.

Thanks. Your edit worked PERFECTLY! Appreciate it.
Pages: 1 2