Conditional for specific article

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malmazan
    Senior Member
    • Jan 2006
    • 974
    • 4.2.X

    [CMS] Conditional for specific article

    I'd like to show some text on specific (arrays of) articles (content id). What would the template conditional be for that?
    Last edited by malmazan; Tue 3 Jan '12, 12:17am. Reason: Typo
    Vote for these issues:
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 74172

    #2
    You'd have to see if the nodeid is exposed where you want to use it. Since you can't use conditionals within content itself, you'd need to make the change to the template. If you want to do it in a Widget, you'd most likely need additional PHP coding.

    so the conditional would be something like:

    <vb:if condition="$nodeid ==XX">do stuff</vb:if>

    Not sure what the specific variable array is though. You'd have to see what variables are exposed where you want to use the conditional at.
    Translations provided by Google.

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

    Comment

    • malmazan
      Senior Member
      • Jan 2006
      • 974
      • 4.2.X

      #3
      Originally posted by Wayne Luke
      You'd have to see if the nodeid is exposed where you want to use it. Since you can't use conditionals within content itself, you'd need to make the change to the template. If you want to do it in a Widget, you'd most likely need additional PHP coding.

      so the conditional would be something like:

      <vb:if condition="$nodeid ==XX">do stuff</vb:if>

      Not sure what the specific variable array is though. You'd have to see what variables are exposed where you want to use the conditional at.
      Specifically i want to use it in the navbar. I use some CMS sections in the navbar and i want to make it obvious visually if the user is in one of those sections like it would happen with forums, blogs or general CMS. And I guess one would find other uses too, like loading special css styles for specific pages.

      The conditional does not seem work in the navbar template, though, or vbcms_page.
      Last edited by malmazan; Tue 3 Jan '12, 3:12am.
      Vote for these issues:

      Comment

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

        #4
        Originally posted by malmazan
        Specifically i want to use it in the navbar. I use some CMS sections in the navbar and i want to make it obvious visually if the user is in one of those sections like it would happen with forums, blogs or general CMS. And I guess one would find other uses too, like loading special css styles for specific pages.
        You'll probably need a plugin. Should look at the plugin that draws the navbar elements in the CMS already.

        The conditional does not seem work in the navbar template, though, or vbcms_page.
        Yeah, I said it wouldn't work without digging through the code to find the exact variable specific to the location you want to use it in.
        Translations provided by Google.

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

        Comment

        • malmazan
          Senior Member
          • Jan 2006
          • 974
          • 4.2.X

          #5
          Originally posted by Wayne Luke
          You'll probably need a plugin. Should look at the plugin that draws the navbar elements in the CMS already.


          Yeah, I said it wouldn't work without digging through the code to find the exact variable specific to the location you want to use it in.

          <vb:if condition="$vbulletin->nodeid == XX">

          does work (at least for navbar and vbcms_page)
          Vote for these issues:

          Comment

          • Travis-Mc
            Member
            • Oct 2009
            • 35
            • 3.8.x

            #6
            Originally posted by malmazan
            <vb:if condition="$vbulletin->nodeid == XX">

            does work (at least for navbar and vbcms_page)
            I was looking for the same information and that worked.. Thanks!

            Originally posted by malmazan
            Specifically i want to use it in the navbar. I use some CMS sections in the navbar and i want to make it obvious visually if the user is in one of those sections like it would happen with forums, blogs or general CMS. And I guess one would find other uses too, like loading special css styles for specific pages.

            The conditional does not seem work in the navbar template, though, or vbcms_page.
            If you're using a CMS section in the main Nav bar, then I think you'll need to use either the $vbulletin->nodeid == XX or $vbulletin->parentnode == XX in your condition to make the navbar "selected". You also need to add something like AND $vbulletin->nodeid != XX to the condition in the Plugin called "Navbar: Insert CMS Navbar Entry" so that both the Home tab and your new tab aren't "selected" at the same time. I'm still trying to figure this all out for myself, but that seems be working so far.

            Comment

            • Travis-Mc
              Member
              • Oct 2009
              • 35
              • 3.8.x

              #7
              Maybe you already have this figured out, but adding AND !in_array($vbulletin->nodeid, array(XX, XX, XX)) to the condition in the plugin called Navbar: Insert CMS Navbar Entry did the trick for me so the home tab isn't selected at the same time as the other new tabs I created.

              Comment

              • malmazan
                Senior Member
                • Jan 2006
                • 974
                • 4.2.X

                #8
                Originally posted by Travis-Mc
                If you're using a CMS section in the main Nav bar, then I think you'll need to use either the $vbulletin->nodeid == XX or $vbulletin->parentnode == XX in your condition to make the navbar "selected"
                Thanks for sharing that. Since there is no documentation or participation from vB on this, we are left to our own devices, and I guess many other people will want to edit their navbars in a similar fashion.

                I have commented out the Home tab myself.

                My verbose conditional for section 3 and articles in section 3:
                Code:
                <vb:if condition="$vbulletin->parentnode == 3 OR $vbulletin->nodeid == 3">
                Vote for these issues:

                Comment

                • malmazan
                  Senior Member
                  • Jan 2006
                  • 974
                  • 4.2.X

                  #9
                  Parentnode aplies to articles within a section, plus sub-sections of that section themselves. However, it does not apply to articles in sub-sections on that section.

                  Here i combined an array of sections (actually, a section -#2- a four sub-sections) with a popup menu so that articles in the sub-sections mark the tab as selected:
                  Code:
                  <li class="popupmenu<vb:if condition="in_array($vbulletin->parentnode, array(2,4,5,6,7)) OR $vbulletin->nodeid == 2"> selected</vb:if>
                  Vote for these issues:

                  Comment

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