Announcement

Collapse
No announcement yet.

sidebar conditionals don't work?

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

  • [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.

  • #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


    • #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


      • #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


        • #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


          • #6
            At the top of your block add:

            global $vbulletin;
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud customization and demonstration site.
            vBulletin 5 Documentation - Updated every Friday. Report issues here.
            vBulletin 5 API - Full / Mobile
            I am not currently available for vB Messenger Chats.

            Comment


            • #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:
               Parse error:  syntax error, unexpected '<' in /home/spider7/public_html/includes/block/html.php(95) : eval()'d code on line 2
              Check out my creative writing forum.

              Comment


              • #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 customization and demonstration site.
                vBulletin 5 Documentation - Updated every Friday. Report issues here.
                vBulletin 5 API - Full / Mobile
                I am not currently available for vB Messenger Chats.

                Comment


                • #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


                  • #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


                    • #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

                      TalkNewsUK - My vBulletin 5.5.4 Demo
                      AdminAmmo - My Cloud Demo

                      Comment


                      • #12
                        Originally posted by Mark.B View Post
                        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 customization and demonstration site.
                        vBulletin 5 Documentation - Updated every Friday. Report issues here.
                        vBulletin 5 API - Full / Mobile
                        I am not currently available for vB Messenger Chats.

                        Comment

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