Announcement

Collapse
No announcement yet.

Customizing Home Button in Navbar

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

  • [CMS] Customizing Home Button in Navbar

    Hi, I'm really hoping to get a bit of help.

    I'd like to modify the link for the Home button on the vBulletin Navbar.

    But I would like to set the URL to a different value IF certain custom user profile fields I've created are populated and match specific values.

    Could you give me some pointers? I've never done vB conditionals before so a quick example of referencing a user profile field would help.

    Thanks,

    Ernest Aleixandre
    Help Desk / Asset Management Software
    K12Advantage.com. Collaboration in K-12 Education

  • #2
    Bump.... I could really use some help with this please.

    I hate to post so many messages asking for help, but there's no documentation online for VB4 as of yet (for some reason the manual is still 3.8). So many of the intricacies of V4 are still a mystery.
    Help Desk / Asset Management Software
    K12Advantage.com. Collaboration in K-12 Education

    Comment


    • #3
      A vB conditional looks like the following:

      <vb:if condition="$something == somevalue">
      HTML to display if true.
      </vb:if>

      or

      <vb:if condition="$something == somevalue">
      HTML to display if true.
      <vb: else/>
      HTML to display if false.
      </vb:if>

      Most template have conditionals. You could do a search in admincp > styles & templates > search templates for "vb:if" to see some.

      I can't be more helpful than that because the question is pretty vague.
      Please- I'm not tech support. Don't send your problem reports to me unless I've asked you to.

      Comment


      • #4
        Thanks for the reply. I'll gladly ellaborate a bit. The conditionals seem easy enough, but I can't even find where in the navbar template the home button link would be.

        By default, the navbar "Home" button links to "content.php"

        Let's say I've created a couple of user profile fields

        "Favorite Subject"
        and
        "Favorite Color"


        and they are userprofile fields: "field2" and "field3" respectively.

        Let's say my favorite hobby was "sports cars" and my favorite color was "red"

        Let's say content section 150 in my CMS contained articles about red sports cars.

        So my logic would be as follows, it's just 2 nested if statements. (I'll have to reasearch the exact syntax to reference user profile fields which I don't know off the top of my head):

        <vb:if condition=$userprofilefield2=="sports cars">
        <vb:if condition=$userprofilefield3=="red">
        $HomeButtonURL="http://www.mysite.com/forums/content.php?150"
        </vb:if>
        <vb: else/>
        $HomeButtonURL="http://www.mysite.com/forums/content.php"
        </vb:if>


        I probably don't need the else statement because the $HomeButtonURL is obviously already pointing to content.php (with no section number specified) by default.

        My problem is that the navbar template is so confusing, I can't figure out:

        • What the name of the HomeButton variable is?
        • Where it's being set?
        • How to properly change it to something else as part of the template code.


        Thanks,
        Help Desk / Asset Management Software
        K12Advantage.com. Collaboration in K-12 Education

        Comment


        • #5
          Bump, I think I can play with the conditionals now.... But I need to figure out where the Home navbar button gets set in the navbar template...

          Can someone provide a snippet of the specific section I'm interested in?

          Thanks,

          Ernest Aleixandre
          Help Desk / Asset Management Software
          K12Advantage.com. Collaboration in K-12 Education

          Comment


          • #6
            Bump.... Is there a vboptions variable that contains the value of the CMS home URL? Kind of like the equivalent of vboptions.forumhome for forums?
            Help Desk / Asset Management Software
            K12Advantage.com. Collaboration in K-12 Education

            Comment


            • #7
              Well, I think I'm finally (slowly) getting on the right track here. I think in order to properly intercept the home button link and change it I'll have to use the following hooks (correct me if I'm wrong):

              template hook: $template_hook['navtab_start']
              phphook: process_templates_complete

              Yes, No???

              Thanks,

              ErnestA.
              Help Desk / Asset Management Software
              K12Advantage.com. Collaboration in K-12 Education

              Comment


              • #8
                Wow... and just like that it works.... Now I just have to build some code around it... But I went into the plugin manager, added a plugin, set the hook to: process_templates_complete and put the following code into the php code area:

                $template_hook['navtab_start'] .= '
                <li><a href="http://www.myurl.com" class="navtab">Home</a></li>
                ';

                Then I just went and disabled the existing home button as documented here:



                And voila! My first (very simple) plugin... Now I just need to write a bit of database code, but finding the hooks was by far the hardest part....

                Thanks everyone....
                Help Desk / Asset Management Software
                K12Advantage.com. Collaboration in K-12 Education

                Comment


                • #9
                  Originally posted by ErnestA View Post
                  Thanks everyone....
                  LOL! Yes, the vB community really came through for you on this problem.
                  Psychlinks Web Services Affordable Web Design & Site Management
                  Specializing in Small Businesses and vBulletin/Xenforo Forums

                  Comment


                  • #10
                    Originally posted by djbaxter View Post
                    LOL! Yes, the vB community really came through for you on this problem.
                    LOL, yes, I did struggle at points... But I still appreciate any help I get (even if it wasn't quite as much as I was hoping for) LOL!
                    Help Desk / Asset Management Software
                    K12Advantage.com. Collaboration in K-12 Education

                    Comment


                    • #11
                      This was very helpful to me. Thanks for posting it!

                      Comment

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