Announcement

Collapse
No announcement yet.

Stuck on Template Conditional for Adsense...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Forum] Stuck on Template Conditional for Adsense...

    I'm trying to set a custom channel for my forums, but for some reason the last ELSE statement that I call CATCH ALL GROUP is applied to every forum. Where am I going wrong?

    Code:
    <!--***** Marketplace Forums *****-->
    <vb:if condition="in_array($forum[forumid], array(319,324,332,336,328,329,323,320,321,326,322,334,325,327,334,331,335,330,302))">
    google_ad_channel ="4017746139";
    
    <!--***** Gettysburg Battle Forum *****-->
    <vb:elseif condition="in_array($forum[forumid], array(256))" />
    google_ad_channel ="5751064266";
    
    <!--***** Other Battle Forums (Fort Sumter, Bull Run, Anteitam, Eastern & Western Theaters, Naval) *****-->
    <vb:elseif condition="in_array($forum[forumid], array(339,342,254,257,306))" />
    google_ad_channel ="3062995846";
    
    <!--***** General Civil War History & What If? Forum *****-->
    <vb:elseif condition="in_array($forum[forumid], array(252,255))" />
    google_ad_channel ="1478081007";
    
    <!--***** Secession & Politics Forum *****-->
    <vb:elseif condition="in_array($forum[forumid], array(253))" />
    google_ad_channel ="9257416969";
    
    <!--***** Ancestry Forum *****-->
    <vb:elseif condition="in_array($forum[forumid], array(303))" />
    google_ad_channel ="3546335823";
    
    <!--***** Reenactors Forum *****-->
    <vb:elseif condition="in_array($forum[forumid], array(259))" />
    google_ad_channel ="6354848725";
    
    <!--***** New Users, Campfire Chat, and News & Blog Reader Forums *****-->
    <vb:elseif condition="in_array($forum[forumid], array(261,248,309))" />
    google_ad_channel ="7915993215";
    
    <!--***** Ladies Tea *****-->
    <vb:elseif condition="in_array($forum[forumid], array(258))" />
    google_ad_channel ="5906747800";
    
    <!--***** Books & Movie Review Forum *****-->
    <vb:elseif condition="in_array($forum[forumid], array(251))" />
    google_ad_channel ="6395363205";
    
    <!--***** Uniform & Artifact Forums *****-->
    <vb:elseif condition="in_array($forum[forumid], array(345))" />
    google_ad_channel ="8573757153";
    
    <!--***** Weapons & Ammo and Skirmishing Forums *****-->
    <vb:elseif condition="in_array($forum[forumid], array(315,312))" />
    google_ad_channel ="3847968861";
    
    <!--*****  Civil War Travelers & Hauntings Forums *****-->
    <vb:elseif condition="in_array($forum[forumid], array(260,305))" />
    google_ad_channel ="0219214733";
    
    <!--***** A to Z Forums *****-->
    <vb:elseif condition="in_array($forum[forumid], array(297,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296))" />
    google_ad_channel ="5205101935";
    
    <!--***** CATCH ALL GROUP *****-->
    <vb:else />
    google_ad_channel ="5240657403";
    </vb:if>

  • #2
    Where are you putting that? Are you sug $forum[forumid] is a valid variable to use there? If it isn't valid, then the else will always be evaled.

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to vbulletin.org
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools &lt;- awesome site for html/css help

    Comment


    • #3
      I hadn't considered that. I'm using the Ad Manager in the built in Advertising tools (vb Admin Control Panel > Advertising > Manage Ads > Ad HTML)

      It says: "Template conditionals and variables are allowed."

      Comment


      • #4
        Originally posted by Lynne View Post
        Where are you putting that? Are you sug $forum[forumid] is a valid variable to use there? If it isn't valid, then the else will always be evaled.
        When you ask where, do you mean where on the page?

        I'm putting this code in the "Below Navbar" position....

        Comment


        • #5
          I thought I found the problem, changed $forum to $foruminfo, but no change, it's still throwing everything to CATCH ALL

          Here is the revised code, client and slot censored:

          Code:
          <!--########### Guest Top 336x280 ##########-->
          <script type="text/javascript"><!--
          google_ad_client = "ca-pub-#############";
          google_ad_slot = "#############";
          google_ad_width = 336;
          google_ad_height = 280;
          
          <vb:if condition="in_array($foruminfo[forumid], array(319,324,332,336,328,329,323,320,321,326,322,334,325,327,334,331,335,330,302))">
          <!--***** Marketplace Forums *****-->
          google_ad_channel ="4017746139";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(256))" />
          <!--***** Gettysburg Battle Forum *****-->
          google_ad_channel ="5751064266";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(339,342,254,257,306))" />
          <!--***** Other Battle Forums (Fort Sumter, Bull Run, Anteitam, Eastern & Western Theaters, Naval) *****-->
          google_ad_channel ="3062995846";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(252,255))" />
          <!--***** General Civil War History & What If? Forum *****-->
          google_ad_channel ="1478081007";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(253))" />
          <!--***** Secession & Politics Forum *****-->
          google_ad_channel ="9257416969";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(303))" />
          <!--***** Ancestry Forum *****-->
          google_ad_channel ="3546335823";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(259))" />
          <!--***** Reenactors Forum *****-->
          google_ad_channel ="6354848725";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(261,248,309))" />
          <!--***** New Users, Campfire Chat, and News & Blog Reader Forums *****-->
          google_ad_channel ="7915993215";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(258))" />
          <!--***** Ladies Tea *****-->
          google_ad_channel ="5906747800";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(251))" />
          <!--***** Books & Movie Review Forum *****-->
          google_ad_channel ="6395363205";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(345))" />
          <!--***** Uniform & Artifact Forums *****-->
          google_ad_channel ="8573757153";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(315,312))" />
          <!--***** Weapons & Ammo and Skirmishing Forums *****-->
          google_ad_channel ="3847968861";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(260,305))" />
          <!--*****  Civil War Travelers & Hauntings Forums *****-->
          google_ad_channel ="0219214733";
          
          <vb:elseif condition="in_array($foruminfo[forumid], array(297,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296))" />
          <!--***** A to Z Forums *****-->
          google_ad_channel ="5205101935";
          
          <vb:else />
          <!--***** CATCH ALL GROUP *****-->
          google_ad_channel ="5240657403";
          
          </vb:if> 
          //-->
          </script>
          <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

          Comment


          • #6
            Just set all [forumid] to ['forumid'], no change, this is a real bugger....

            Comment


            • #7
              Replacing $foruminfo['forumid'], with $forumid, and other various changes, no luck...

              Comment


              • #8
                Try $GLOBALS['forumid']

                Please don't PM or VM me for support - I only help out in the threads.
                vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                Want help modifying your vbulletin forum? Head on over to vbulletin.org
                If I post CSS and you don't know where it goes, throw it into the additional.css template.

                W3Schools &lt;- awesome site for html/css help

                Comment


                • #9
                  Originally posted by Lynne View Post
                  Try $GLOBALS['forumid']
                  That fixed it! I have some testing to do, but it seems to be functioning perfectly. I'll post the final revision once I'm satisfied it's fully functional. Thanks Lynne!

                  Comment

                  widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                  Working...
                  X