Announcement

Collapse
No announcement yet.

Forum Icons & Conditions

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

  • Forum Icons & Conditions

    I want to give most of my forums unique icons on the forumdisplay and index page. Currently I use the following code in forumhome_forumbit_level1_post and forumhome_forumbit_level2_post:

    <if condition="$forumid == 2 or $forumid == 4 or $forumid == 9 or $forumid == 12 or $forumid == 16"><div class="smallfont"><a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]"><img class="icon32" src="../images/icons/$forum[forumid]-32.gif" alt="$forum[title]" /></a></div></if>
    And I will need to add a lot more forums to that, which I each time have to add/modify in two templates too, but I think that there should be an easier way, for example if it would be possible to add a custom field to a forum (comparable to a user profile field) so I can let a condition check that, i.e.:
    <if condition="$forum['icon']"><div class="smallfont"><a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]"><img class="icon32" src="../images/icons/$forum[forumid]-32.gif" alt="$forum[title]" /></a></div></if>
    How difficult would it be to add field like this to the database and to make it possible to use it with conditions?
    Last edited by Ogmuk; Mon 12th Apr '04, 5:41am.

  • #2
    What I would do is setup an array of forumids in the phpinclude_start template and use the in_array() function in the templates to check for matches. This way you only have to edit the phpinclude_start template when you add more forumids.

    Go to your:

    Admin CP -> Styles & Templates -> Style Manager -> -> PHP Include Code Templates -> phpinclude_start

    Add this code to that template:

    PHP Code:
    $forumicon = array(2491216); 
    The numbers inside the parenthesis are the forumids of the forums for which you want icons to show. Change these numbers appropriately, separating them by commas as shown above.

    Then in your forumhome_forumbit_level1_post and forumhome_forumbit_level2_post templates, replace the current conditions with this:

    Code:
    <if condition="in_array($forum['forumid'], $GLOBALS['forumicon'])">
    	YOUR CODE HERE
    </if>
    If you want to add an icon to a new forum, just add its forumid to your phpinclude_start template.

    Comment


    • #3
      Great. I'll try that, thanks for the tip Jake.

      Comment


      • #4
        Works like a charm, thanks!

        Comment


        • #5
          Wow I wanna do this!!

          Jake Bunce that is too clever!

          Ogmuk, I like your naming convention for the logo files - that makes it work easily too. Can you post the forumhome_forumbit_level1_post and forumhome_forumbit_level2_post code that you ended out using?


          Right now when there are new posts, my forum icon is a reddened version of the forum icon when there are no newposts. I really like that. Can I still do that with this?

          i.e., If I customize each forum to the person's logo, can I show

          instead of: forum_new.gif, forum_old.gif
          show: forum23_new.gif, forum23_old.gif

          Stachel

          Comment


          • #6
            Heyyyyy, I bet I could use that conditional that Jake wrote to display a custom header row above the breadcrumb area when

            forumdisplay.php happens!
            Right?!?

            Comment


            • #7
              With the forumids specified in the phpinclude_start template, you can use that condition in any template to check the forumid.

              The only thing that might change is the variable for the forumid in the condition. For forumdisplay and showthread pages you need to use $forumid instead of $forum[forumid]:

              Code:
              <if condition="in_array($forumid, $GLOBALS['forumicon'])">
              	YOUR CODE HERE
              </if>

              Comment


              • #8
                Jake Thanks!

                Thanks Jake! That diff in variable names would have tripped me up for sure.

                I was about to start implementing this, but something bizarre...

                The current icons that appear *now* on my forum are:
                - forum_new.gif (when new posts exists - the brighter red version)
                - forum_old.gif (no new posts)

                But when I search for forum_new.gif, I **only** get a hit in help_bbcodes template.

                How can this be?

                It's not even referenced in forumhome template.

                Stachel

                Comment


                • #9
                  cause its not in forumhome.

                  look for forum_$forum[statusicon].gif to find where your forum icons are referenced.

                  Comment


                  • #10
                    Thanks Vigile!

                    What is the diff between what forumbit_Level1... controls vs what level2 controls?

                    Comment


                    • #11
                      Originally posted by Stachel
                      What is the diff between what forumbit_Level1... controls vs what level2 controls?
                      The level 1 templates are used for forums at the first level relative to the current level. Level 2 templates are used for level 2 forums.

                      For example, on this page "vBulletin 3" is a level 1 forum while "vBulletin 3 Suggestions and Feedback" is a level 2 forum. On this page "vBulletin 3 Suggestions and Feedback" is a level 1 forum.

                      Comment


                      • #12
                        Originally posted by Jake Bunce
                        relative to the current level
                        Ohhhhhhhh that's tricky! Seems like the key thing is "relative to the current level."

                        Thanks Jake!

                        Stachel

                        Comment


                        • #13
                          Hi,

                          I didn't get how exactly this is being done. I got about 100 Boards, now 2 of those should have a unique icon.

                          Then it's no good idea to replace _all_ the code in forumhome_forumbit_level1_post (and 2), is it? Then i'd have to set every forum in phpinclude?

                          Comment


                          • #14
                            Originally posted by Jake Bunce
                            What I would do is setup an array of forumids in the phpinclude_start template and use the in_array() function in the templates to check for matches. This way you only have to edit the phpinclude_start template when you add more forumids.

                            Go to your:

                            Admin CP -> Styles & Templates -> Style Manager -> -> PHP Include Code Templates -> phpinclude_start

                            Add this code to that template:

                            PHP Code:
                            $forumicon = array(2491216); 
                            The numbers inside the parenthesis are the forumids of the forums for which you want icons to show. Change these numbers appropriately, separating them by commas as shown above.

                            Then in your forumhome_forumbit_level1_post and forumhome_forumbit_level2_post templates, replace the current conditions with this:

                            Code:
                            <if condition="in_array($forum['forumid'], $GLOBALS['forumicon'])">
                            	YOUR CODE HERE
                            </if>
                            If you want to add an icon to a new forum, just add its forumid to your phpinclude_start template.
                            Jake, does this still work in vB3.0.5? I'm having trouble getting in_array to work with 2 previously set variables; http://www.vbulletin.com/forum/showthread.php?t=126191

                            Comment


                            • #15
                              Originally posted by stormblast-
                              Hi,

                              I didn't get how exactly this is being done. I got about 100 Boards, now 2 of those should have a unique icon.

                              Then it's no good idea to replace _all_ the code in forumhome_forumbit_level1_post (and 2), is it? Then i'd have to set every forum in phpinclude?
                              The template conditional makes it so the code inside the conditional only shows up for the forums you specify.

                              I also posted this thread a while ago which might be of help.

                              Comment

                              Loading...
                              Working...
                              X