No announcement yet.

Using variables in templates

  • Time
  • Show
Clear All
new posts

  • Using variables in templates

    I know about using the phpinclude template but it's not able to do what I need...Or maybe I just don't know how to do it so it works. Here's what I'm trying to do:

    I'm creating tabs for some of the areas in the forum and removing them from the navbar:

    Home <> Community <> FAQs <> Rules <> etc.

    The color theme for my tabs are: (Blue: current page AND Orange: other pages)

    In php, I could have a variable that I use in the header of each page. For example:

    The home page : $tabactive = 1;
    The community page: $tabactive = 2;
    The FAQs page: $tabactive = 3;
    and so on.

    In my one header file, I could include something like:

    <if ($tabactive == 1)>
    the home button is blue
    the home button orange
    </end if>

    I would code every tab with a similar if/else and it would load appropriately based on the value for $tabactive on each page.

    How do I accomplish this using the templates?

    I know this can be accomplished by creating different header templates, but I'm trying to avoid that unless absolutely necessary. [coupons & comparison shopping] [new forum]

  • #2
    You don't even have to set variables in the phpinclude page, you can use THIS_SCRIPT to determine where you are on vbulletin.

    <if condition="THIS_SCRIPT == 'index'">
    <!-- we are on index.php, forumhome, make it blue -->
    <else />

    <if condition="THIS_SCRIPT == 'faq'">
    <!-- we are on faq.php faq section, make it blue -->
    <else />
    <!-- we are not on index.php or faq.php - make it orange -->



    • #3
      That's exactly what I needed. I tried it and it works great!!!

      ~ Thanks ~ [coupons & comparison shopping] [new forum]


      • #4
        Just another question...

        How can I do similar for page that's in a different directory than the forum?

        I know you don't do mod support but I thought you might know the answer. I installed the vBAdvanced Homepage mod which is at: All of the regular forum pages are at:

        I added the following to the phpinclude_start template:

        define('THIS_SCRIPT2', '../page');

        Then, in the template that I wanted to use this in, I added:

        <if condition="$THIS_SCRIPT2 == 'index'">
        do something
        <else />
        do this instead

        It doesn't work. Am I doing something wrong? [coupons & comparison shopping] [new forum]


        • #5
          Sorry, can't provide support for things we did not write.

          If vB Advanced is properly integrated and using vb's features, it might have define this script set in its .php pages. You can use index.php for your frontpage and forum.php (instead of forum/index.php) for your forum. Instead of having it in its own directory.


          • #6

            I'lll check
   [coupons & comparison shopping]
   [new forum]


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