Using variables in templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eblivion
    Member
    • Sep 2004
    • 48
    • 3.0.6

    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
    <else>
    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.
    http://www.bargainwheel.com [coupons & comparison shopping]
    http://www.bargainwheel.com/forum/ [new forum]
  • Floris
    Senior Member
    • Dec 2001
    • 37767

    #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 -->
    </if>

    </if>

    Comment

    • eblivion
      Member
      • Sep 2004
      • 48
      • 3.0.6

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

      ~ Thanks ~
      http://www.bargainwheel.com [coupons & comparison shopping]
      http://www.bargainwheel.com/forum/ [new forum]

      Comment

      • eblivion
        Member
        • Sep 2004
        • 48
        • 3.0.6

        #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: mydomain.com/index.php. All of the regular forum pages are at: mydomain.com/forum/xxx.php

        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
        </if>

        It doesn't work. Am I doing something wrong?
        http://www.bargainwheel.com [coupons & comparison shopping]
        http://www.bargainwheel.com/forum/ [new forum]

        Comment

        • Floris
          Senior Member
          • Dec 2001
          • 37767

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

          Comment

          • eblivion
            Member
            • Sep 2004
            • 48
            • 3.0.6

            #6
            Thanks,

            I'lll check vbulletin.org
            http://www.bargainwheel.com [coupons & comparison shopping]
            http://www.bargainwheel.com/forum/ [new forum]

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            😀
            😂
            🥰
            😘
            🤢
            😎
            😞
            😡
            👍
            👎