sidebar conditionals don't work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lpspider
    Senior Member
    • Oct 2005
    • 295
    • 3.6.x

    [Forum] sidebar conditionals don't work?

    I have an ad block on my forum sidebar. I'd like to make it so members of a supporter usergroup don't see the ads. However, this conditional - as well as others I've tried - doesn't work. Tips?

    Code:
    <vb:if condition="is_member_of($bbuserinfo, 6)">
    
    <vb:else />
    
    <center>
    google adwords</center></vb:if>
    Check out my creative writing forum.
  • Lynne
    Former vBulletin Support
    • Oct 2004
    • 26255

    #2
    What type of block is it? I don't believe that will work in any type of block - it's not text, it's not html, and it's not php. Just write up a php block and it should work.

    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

    • Lpspider
      Senior Member
      • Oct 2005
      • 295
      • 3.6.x

      #3
      I've tried it with all blocks, including the php block.

      I'm trying various php codes not without success.
      Check out my creative writing forum.

      Comment

      • Lynne
        Former vBulletin Support
        • Oct 2004
        • 26255

        #4
        Can we see what code you wrote as a php block? (That code you wrote will not work in any type of block.)

        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

        • Lpspider
          Senior Member
          • Oct 2005
          • 295
          • 3.6.x

          #5
          Here's what I have so far:

          Code:
          <?php
          $ad='<center>
          <script type="text/javascript"><!--
          google_ad_client = "ca-pub-xxxxxxx";
          /* WF sidebarhome */
          google_ad_slot = "xxxxxxxx";
          google_ad_width = 250;
          google_ad_height = 250;
          //-->
          </script>
          <script type="text/javascript"
          src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
          </script></center>';
          if (is_member_of($vbulletin->userinfo, 6))
          ;
          
          else{
          return $ads;
          }
          ?>
          I know this is basic but I'm not fluent in php... haven't used it in a few years. :/

          Also, I've just realized that this conditional won't eliminate a blank sidebar block for usergroup 6. Is there a better way to make the sidebar ad not visible to a certain usergroup(s)?
          Check out my creative writing forum.

          Comment

          • Wayne Luke
            vBulletin Technical Support Lead
            • Aug 2000
            • 74122

            #6
            At the top of your block add:

            global $vbulletin;
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment

            • Lpspider
              Senior Member
              • Oct 2005
              • 295
              • 3.6.x

              #7
              New code:

              Code:
              global $vbulletin;
              <?php
              $ad='<center>
              <script type="text/javascript"><!--
              google_ad_client = "ca-pub-xxxxxx";
              /* WF sidebarhome */
              google_ad_slot = "xxxx";
              google_ad_width = 250;
              google_ad_height = 250;
              //-->
              </script>
              <script type="text/javascript"
              src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
              </script></center>';
              if (is_member_of($vbulletin->userinfo, 6)){
              ;
              }
              else{
              return $ads;
              }
              ?>
              It's not working though, throws two instances of this error on the top of forum-home:

              Code:
               [B]Parse error[/B]:  syntax error, unexpected '<' in [B]/home/spider7/public_html/includes/block/html.php(95) : eval()'d code[/B] on line [B]2[/B]
              Check out my creative writing forum.

              Comment

              • Wayne Luke
                vBulletin Technical Support Lead
                • Aug 2000
                • 74122

                #8
                Sorry... You shouldn't need the <?php and ?>. You're not creating a file.
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud demonstration site.
                vBulletin 5 API

                Comment

                • Lynne
                  Former vBulletin Support
                  • Oct 2004
                  • 26255

                  #9
                  And instead of this:
                  PHP Code:
                  if (is_member_of($vbulletin->userinfo6)){ ; } else{ return $ads; } 
                  Try this:
                  PHP Code:
                   if (!is_member_of(vB::$vbulletin->userinfo6)){ return $ads; } 

                  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

                  • Lpspider
                    Senior Member
                    • Oct 2005
                    • 295
                    • 3.6.x

                    #10
                    Still not working, but closer...

                    Current code:

                    Code:
                    global $vbulletin;
                    $ad='<center>
                    <script type="text/javascript"><!--
                    google_ad_client = "ca-pub-xxxxxxx";
                    /* WF sidebarhome */
                    google_ad_slot = "xxxxx";
                    google_ad_width = 250;
                    google_ad_height = 250;
                    //-->
                    </script>
                    <script type="text/javascript"
                    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                    </script></center>';
                     if (!is_member_of(vB::$vbulletin->userinfo, 6)){ return $ads; }
                    No error this time, but the ad will not display at all. No code and ad block do not show in the sidebar whatsoever. I've tried it with different usergroups and tried clearing the cache, no luck.

                    Thanks for your help.
                    Check out my creative writing forum.

                    Comment

                    • Mark.B
                      vBulletin Support
                      • Feb 2004
                      • 24287
                      • 6.0.X

                      #11
                      Is the variable intentionally different?

                      Just looking at that block of code in isolation - You seem to be creating $ad and then returning $ads. Wouldn't $ads be empty as it doesn't exist?

                      Or have I misunderstood what the code is doing (being the world's most lousy coder that's possible).
                      MARK.B
                      vBulletin Support
                      ------------
                      My Unofficial vBulletin 6.0.0 Demo: https://www.talknewsuk.com
                      My Unofficial vBulletin Cloud Demo: https://www.adminammo.com

                      Comment

                      • Wayne Luke
                        vBulletin Technical Support Lead
                        • Aug 2000
                        • 74122

                        #12
                        Originally posted by Mark.B
                        Just looking at that block of code in isolation - You seem to be creating $ad and then returning $ads. Wouldn't $ads be empty as it doesn't exist?
                        This would actually be correct. Good catch.
                        Translations provided by Google.

                        Wayne Luke
                        The Rabid Badger - a vBulletin Cloud demonstration site.
                        vBulletin 5 API

                        Comment

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