Announcement

Collapse
No announcement yet.

vb:if and array

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

  • [Forum] vb:if and array

    I have a vb:if statement in a custom block for my sidebar.
    I tested the array itself on a test site so I know it works.
    When I tried to use it, it showed the data when I suspected it would not.

    I tried this
    <vb:if condition="in_array($foruminfo['forumid'], array(500,501))">
    stuff here
    </vb:if>

    I do not have a forum with an ID of 500 or 501, so I presumed nothing would show. I also presumed if the vb:if statement was incorrect, I would see nothing.

    I am not very familiar with vb array's, where did I go wrong?
    Cliff
    PathLabTalk
    Square Wheels Cycling

  • #2
    Originally posted by dilbert View Post
    I have a vb:if statement in a custom block for my sidebar.
    I tested the array itself on a test site so I know it works.
    When I tried to use it, it showed the data when I suspected it would not.

    I tried this
    <vb:if condition="in_array($foruminfo['forumid'], array(500,501))">
    stuff here
    </vb:if>

    I do not have a forum with an ID of 500 or 501, so I presumed nothing would show. I also presumed if the vb:if statement was incorrect, I would see nothing.

    I am not very familiar with vb array's, where did I go wrong?
    Try changing $foruminfo['forumid'] to $GLOBALS[forumid]
    MARK.B | vBULLETIN SUPPORT

    TalkNewsUK - My vBulletin 5.5.6 Demo
    AdminAmmo - My Cloud Demo

    Comment


    • #3
      That did the same thing.

      I guess I don't understand how vb:if works. Is it like a regular if statement where conditions must be met before an action is taken? So if my forum wasn't 500 or 501 then the if statement won't process? If that's true, then why does the if statement process either way? I know the varibles don't work on all pages, but shouldn't the if statement work on all pages?

      Thanks
      Cliff
      PathLabTalk
      Square Wheels Cycling

      Comment


      • #4
        dilbert - I'm no expert, so be ready to reject anything I say.

        I understand that vb:if statements can only be used in templates. That might mean that you can't include php functions as the condition you are testing.

        Take a look through existing templates to see the sorts of conditions that are being tested.

        In your case you could say <vb:if condition="is_member_of($foruminfo['forumid'], 500,501)">

        There's an interesting article on template conditionals at http://www.vbulletin.org/forum/showthread.php?t=231525

        Comment


        • #5
          is_member_of is for checking membergroups and not forums

          dilbert what templates are you using this conditional in?

          Comment


          • #6
            Thanks Zachery, sorry I missed this post.
            It's not in a template, it's from a custom mod, EveryWhere Sidebar, so I fear getting a reply of we can't help with that.
            I understand you can't officially help with custom mods, can you help with how to get vb conditionals to work with them?

            Thanks
            Originally posted by Zachery View Post
            is_member_of is for checking membergroups and not forums

            dilbert what templates are you using this conditional in?
            Cliff
            PathLabTalk
            Square Wheels Cycling

            Comment


            • #7
              You likely don't have access to what you need in that template by default without globaling or pre-registering some data.

              Comment


              • #8
                Thanks, how does one do that?
                Originally posted by Zachery View Post
                You likely don't have access to what you need in that template by default without globaling or pre-registering some data.
                Cliff
                PathLabTalk
                Square Wheels Cycling

                Comment

                Related Topics

                Collapse

                Working...
                X