MyBB Ideas

The MyBB Ideas site allows users to suggest new features and changes in MyBB and the MyBB Group to easily review them to decide what direction MyBB should head in. Search existing ideas.

Template Conditionals

64 votes

Submitted by labrocca, 19th February 2007, 11:04:16 PM

It would be nice if IF statements can be created within the templates. Like IF group=admins then {show this}. It would be very nice to have this feature and could be widely used for all sorts of little tidbits.

16 Comments

  1. Not really... Keep those things for the php.

    zaher1988, 19th February 2007, 11:06:28 PM
  2. Either make as a plugin or not at all. php already does this job so leave it for that.

    DrPoodle, 19th February 2007, 11:08:44 PM
  3. But Dr. Poodle you can't use php inside templates..that's why conditionals would be useful. I would make this a plugin but imho it would be very complex and even then may not work properly. Also if the plugin system changes in a new version you may have a lot of templates that will have to be reverted and all your changes lost.

    Is your comment unbiased or are you just posting something negative because it's me that posted the idea?

    labrocca, 19th February 2007, 11:24:13 PM
  4. I Like this Idea :)

    pepotiger, 19th February 2007, 11:57:23 PM
  5. I'm half-half for this idea. I think it's a very easy way to make templates even more dynamic without having to mess around with the PHP code, but as zaher1988 mentioned, we have tried to keep coding, and HTML layout, and styles as separate as possible so that you will know exactly where to find something, instead of having to check a number of places.

    DennisTT, 20th February 2007, 12:01:07 AM
  6. Labrocca:

    My comment is unbiased and I am shocked that you would think otherwise. I don't think it should be a default feature because this can be done by simply editing a file with the same code. I think the template system is perfect at the moment. Adding if functions as default would just over-complicate things.

    DrPoodle, 20th February 2007, 12:52:58 AM
  7. Sorry Poodle no offense...I just been catching some flack lately for my vocal ideas and opinions. Sometimes I think people just have it out for me...paranoia I guess. Sorry about that.

    labrocca, 20th February 2007, 1:02:09 AM
  8. I'd like to see this; I have a conditional mod on my forum that made some parts of editing my template a breeze - such as adding in some things that only appear for guests and if it's the first post, and whatnot.

    The earliest I can see it coming is 2.0.

    Justin S., 20th February 2007, 1:08:49 AM
  9. This is a good idea.

    I'd like to do IF commands on my forum...

    if($user == 'admin') {

    or possibly a special MyBB command

    <[[IF ADMIN]]><a href="admin_custom.php">IF_FTW</a><[[end IF]]>

    stemount, 20th February 2007, 1:31:19 AM
  10. Yes this would even eliminate some of the guest templates that could simply be integrated into the regular template and IF statemented instead. It would be helpful for guests, bots, admins, and special member groups.

    labrocca, 20th February 2007, 7:15:09 AM
  11. I believe this should be a plugin. Just add a hook to class_templates.php and parse on the fly. I'm sure one small modification wouldn't hurt. Especially when it's a file that's barely gets touched.

    Ryan Gordon, 20th February 2007, 7:40:41 AM
  12. This is a great idea labrocca. I could probably find some use for it :)

    Dr Small, 21st February 2007, 1:35:00 AM
  13. i have made this with code changes in inc/functions.php and inc/class_templates.php
    and it works perfectly IF statements inside templates :)

    i give you example how it works with which code? like this:

    <if condition=$mybb->user['username']== Hasann
    <then>
    yes, my name is Hasann
    <else />
    no, my name is Hüseyinn
    </if>

    :)))))))))))))))))

    HASANN, 22nd February 2007, 3:05:51 AM
  14. My concern tikitiki is then when I do have a plugin for template conditionals that any template changes on updates will go haywire. Also I do refuse to do even a single core file change so I am not even sure this can be done as a pure plugin. It's a bit beyond my reach to create one and the current code for conditionals is a bunch of core changes. I am not asking for this immediately but I believe that with 2.0 it would be a big plus. I can certainly want but I do request this feature. So far the votes for it have been fairly good.

    labrocca, 22nd February 2007, 8:20:00 AM
  15. After spending hours skinning another piece of forum software (with template conditionals) anything without plain out annoys me.

    It save a huge amount of time, and allows for far more flexibility.

    Just watch out how it's implemented. The other BB I skinned let you run any PHP code: set variables (useful), run mail() (dangerous), etc

    Detruire, 24th February 2007, 5:06:43 AM
  16. This could be usefull in 1.4 brand, Nice Idea

    in my board with 1.2x new users aren´t allowed to PM but they still have that "PM link" there...

    aglioeolio, 11th February 2008, 2:21:21 PM

Post a Comment

Before you can post a comment you must be a registered member of the MyBB Community Forums.

If you already have an account, log-in to it to post a comment or if you don't register a new account.