Jump to content

vBulletin 4 Template Conditionals List

- - - - -

  • Please log in to reply
29 replies to this topic

#1 Nick

Nick

    Guru

  • Founders
  • 7451 posts
  • LocationTampa, FL

Posted 07 September 2009 - 01:10 PM

This is an updated list of conditionals with the syntax used in vBulletin 4. A preview of the syntax was made available on Wayne Luke's site, vBCodex and is the basis from which I have formed this list.

As of writing, vB 4 isn't even out yet (it's in Alpha testing) so this won't be of use to you just yet, but at least you know it's here and we have it. Might as well add it to your bookmarks now so you have it when you need it. :cool:

------

Viewer is a guest
<vb:if condition="$show['guest']"> </vb:if>
Viewer is a member
<vb:if condition="$show['member']"> </vb:if>
Viewer is in a specific usergroup (In this example, 6 is the usergroup ID. You can add more using commas)
<vb:if condition="$is_member_of($bbuserinfo,6)" /></vb:if>
Viewer has a specific User ID (user ID = X)
<vb:if condition="$bbuserinfo['userid'] == X"> </vb:if>
------


This list will be updated and maintained as time goes on and more information becomes available. :)
Best Regards,
Nick

#2 Michael

Michael

    Zealot

  • Registered Members
  • 1753 posts

Posted 07 September 2009 - 01:12 PM

Awesome Nick, I have bookmarked! ;)

#3 David McHenry

David McHenry

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 830 posts

Posted 07 September 2009 - 04:21 PM

any reason why the moved from the easy format of

<if condition="$show[member]">

to the new syntax?

Is the <vb: part of it, so it can be broken down to application specific sections? Like their new CMS

<cms: if condition="$show['guest']"> </cms:if>

Edited by David McHenry, 07 September 2009 - 04:24 PM.

Looking for web hosting? Look no further than Web Hosting Review Shop be sure to leave your hosting experience as well.
Personal Blog of BS

#4 Michael

Michael

    Zealot

  • Registered Members
  • 1753 posts

Posted 07 September 2009 - 04:29 PM

BSMedia said:

any reason why the moved from the easy format of

<if condition="$show[member]">

to the new syntax?

Is the <vb: part of it, so it can be broken down to application specific sections? Like their new CMS

<cms: if condition="$show['guest']"> </cms:if>

I wouldnt be surprised if that is true, sounds dead on to me :D

#5 Nick

Nick

    Guru

  • Founders
  • 7451 posts
  • LocationTampa, FL

Posted 07 September 2009 - 04:30 PM

BSMedia said:

any reason why the moved from the easy format of

<if condition="$show[member]">

to the new syntax?

Is the <vb: part of it, so it can be broken down to application specific sections? Like their new CMS

<cms: if condition="$show['guest']"> </cms:if>
Wayne explains some of the reasons for the changes, here:

Quote

The problem though with template hooks, <if> conditionals and <phrase> tags is that it made it very difficult to work with templates in tools like Dreamweaver and Go Live!. Syntax highlighting was off, variables didn't render and preview was a general mess. With the move to an object oriented template system in vBulletin 4, this would have become even worse over time. So the developers decided to move vBulletin's proprietary tags to their own namespace and create a better way of presenting variables within the templates.

Template First Look at vBulletin 4 Template Variables - vBCodex
Best Regards,
Nick

#6 twhiting9275

twhiting9275

    Champion

  • Registered Members
  • PipPipPipPip
  • 372 posts

Posted 07 September 2009 - 04:50 PM

So in order to help those that can't do the job right, we get stuck with more complicated templates. NOT good

#7 kneel

kneel

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 554 posts

Posted 08 September 2009 - 06:24 AM

waynes site is an amazing thing...

thanks for this mane!!

#8 cheat-master30

cheat-master30

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 793 posts

Posted 08 September 2009 - 01:56 PM

Thanks for the list Nick. This should help anyone who wants to start converting the simpler modifications on their forum to vBulletin 4 versions.
DS Ultimate Forums- A Nintendo DS forum

-cheat-master30; Someone who probably posts way more on forums than anyone ever should.

#9 Lynne

Lynne

    Champion

  • Mentors
  • PipPipPipPip
  • 326 posts

Posted 08 September 2009 - 03:04 PM

twhiting9275 said:

So in order to help those that can't do the job right, we get stuck with more complicated templates. NOT good
How is simply sticking a vb: in front of the if "more complicated". It really is just that simple.

#10 Michael

Michael

    Zealot

  • Registered Members
  • 1753 posts

Posted 08 September 2009 - 03:11 PM

Lynne said:

How is simply sticking a vb: in front of the if "more complicated". It really is just that simple.

I think adding anything extra to the code which is already there may make it more daunting for beginners to look at. The normal ifs when I first seen them looked really hard to use and with adding vb: or other prefixes it may make the first look of them even more daunting to beginners to the software.

#11 Chani

Chani

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 885 posts

Posted 08 September 2009 - 04:04 PM

I both like this and dislike this.

I think it'll be cool to be able to add PHP into your templates, but then again, having PHP and HTML separate (gently merged) in vB's current form is one of the things that makes it so easy to edit. (Ever templated a Zen-Cart site??? :eek: )

As long as the code remains somewhat portable within the site, I'm sure I'll get used to it. :)

10% of all purchases using this link will go to AA.
Don't forget Coupon Code 10FOR2010 for a 10% discount.
[SIGPIC][/SIGPIC]


#12 Wayne Luke

Wayne Luke

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 993 posts

Posted 08 September 2009 - 04:12 PM

The problem is the current syntax is invalid and causes validation to fail if you check just a template. However by adding a namespace, you can get around that and it is the proper way to code it.

The most important part though is that is modular and expandable. The new system allows the use of loops in templates as well as special variable syntax for parsing things like dates, times, and numbers within the templates instead of the PHP Code. This allows you to present more customized experiences to your end users as an administrator without worrying about the PHP code. It allows programmers to give you more tools through addons to customize it even more.

I doubt there will be PHP in the templates and the new syntax is less PHP-like than before. You'll need to keep your PHP in plugins where it belongs.
vBCodex - Get help building your vBulletin community.
Get Gravatar support for your vBulletin community.
-- Please do not contact me via PM for vBulletin Support.

#13 David McHenry

David McHenry

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 830 posts

Posted 08 September 2009 - 04:28 PM

Wayne Luke said:

The problem is the current syntax is invalid and causes validation to fail if you check just a template. However by adding a namespace, you can get around that and it is the proper way to code it.

The most important part though is that is modular and expandable. The new system allows the use of loops in templates as well as special variable syntax for parsing things like dates, times, and numbers within the templates instead of the PHP Code. This allows you to present more customized experiences to your end users as an administrator without worrying about the PHP code. It allows programmers to give you more tools through addons to customize it even more.

I doubt there will be PHP in the templates and the new syntax is less PHP-like than before. You'll need to keep your PHP in plugins where it belongs.


Thanks for the update on why the change occurred. I personally don't find it any more difficult to stick vb in front of a condition.
Looking for web hosting? Look no further than Web Hosting Review Shop be sure to leave your hosting experience as well.
Personal Blog of BS

#14 Webmist

Webmist

    Champion

  • Registered Members
  • PipPipPipPip
  • 301 posts
  • LocationUS

Posted 14 September 2009 - 07:22 PM

You know this reminds me of coding for Joomla. :doh:

Do you think we'll have an actual list of conditionals? I would really like to see that in the release.
June -- Luna Procer
_____________________________________
** giving hugs to the new members **
Vos planto mihi sentio bonus.

#15 David McHenry

David McHenry

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 830 posts

Posted 14 September 2009 - 07:46 PM

Webmist said:

You know this reminds me of coding for Joomla. :doh:

Do you think we'll have an actual list of conditionals? I would really like to see that in the release.


From the looks of it, they aren't really changing over current conditionals. I'd imagine there maybe some new ones, and some small changes/tweaks to the current ones, but for the most part it seems its simply a new syntax to prefix the conditional with <vb:
Looking for web hosting? Look no further than Web Hosting Review Shop be sure to leave your hosting experience as well.
Personal Blog of BS

#16 Webmist

Webmist

    Champion

  • Registered Members
  • PipPipPipPip
  • 301 posts
  • LocationUS

Posted 14 September 2009 - 08:23 PM

From the looks of it yeah it shouldn't be to hard to adjust. But you gotta admit it does remind look like one. I like my smarty templates so these type of conditionals wheree....different to get used to.

I'm actually quite comfortable with the ones for vB.

Still hope the make a list though.
June -- Luna Procer
_____________________________________
** giving hugs to the new members **
Vos planto mihi sentio bonus.

#17 Wayne Luke

Wayne Luke

    Grand Master

  • Registered Members
  • PipPipPipPipPip
  • 993 posts

Posted 14 September 2009 - 10:54 PM

It would be almost impossible list all conditionals available for vBulletin. Any variable available to templates can be used in a conditional and than in any combination allowed for conditional constructs in PHP. Just taking the 458 settings/options and the 60 odd fields in the user table gives you 27480 potential conditionals using the && operator alone. Now not all would be viable or worthwhile but they are possible. That doesn't account for combinations where you can use ==. !=. >=, <=, || or compound conditionals. It also doesn't account for usergroups, permissions, forum information, custom profile fields and about 300 other variables that are available on every page.

Next you have to account for scope. For instance the userinfo array is not available in the postbit. You have to use the postinfo array.

Then you would have to account for conditionals that are available in specific templates. Especially since variables have to be registered with templates before they are available in vBulletin. So you won't necessarily be able to use a conditional you saw in the footer inside the header template.

Needless to say any sort of comprehensive list will be larger than the current vBulletin manual which is over 500 pages. It would take hundreds of hours to produce. The benefit just isn't there. It is much easier to answer threads that ask what conditional to use and a vBulletin staff member posts it for them.
vBCodex - Get help building your vBulletin community.
Get Gravatar support for your vBulletin community.
-- Please do not contact me via PM for vBulletin Support.

#18 Michael

Michael

    Zealot

  • Registered Members
  • 1753 posts

Posted 15 September 2009 - 02:27 AM

Wayne Luke said:

It would be almost impossible list all conditionals available for vBulletin. Any variable available to templates can be used in a conditional and than in any combination allowed for conditional constructs in PHP. Just taking the 458 settings/options and the 60 odd fields in the user table gives you 27480 potential conditionals using the && operator alone. Now not all would be viable or worthwhile but they are possible. That doesn't account for combinations where you can use ==. !=. >=, <=, || or compound conditionals. It also doesn't account for usergroups, permissions, forum information, custom profile fields and about 300 other variables that are available on every page.

Next you have to account for scope. For instance the userinfo array is not available in the postbit. You have to use the postinfo array.

Then you would have to account for conditionals that are available in specific templates. Especially since variables have to be registered with templates before they are available in vBulletin. So you won't necessarily be able to use a conditional you saw in the footer inside the header template.

Needless to say any sort of comprehensive list will be larger than the current vBulletin manual which is over 500 pages. It would take hundreds of hours to produce. The benefit just isn't there. It is much easier to answer threads that ask what conditional to use and a vBulletin staff member posts it for them.

Of course a good list of the most commonly used template conditionals is handy, I know I have them bookmarked for when I need to use one of them somewhere. The more advanced ones I tend to ask for on forums.

#19 Peacelily

Peacelily

    Adept

  • Registered Members
  • 245 posts

Posted 15 September 2009 - 04:21 AM

Quote

The most important part though is that is modular and expandable.


:thumbup:

Thanks for posting these Nick and to Wayne for the codex. I am always just so dang happy that I have vBulletin that if you told me I had to use these conditionals while wearing purple pajamas with koala bears on them and singing Yankee Doodle Dandy on BlogTV in front of 50,000 people, I'd still be happy as long as I never have to try to do a hack in phpBB ever again as long as I live.

#20 Brandon Sheley

Brandon Sheley

    a proud daddy!

  • Premium Members
  • 761 posts

Posted 10 October 2009 - 10:50 PM

Great thread, thanks for the info Nick and Wayne

My Company: Services | Clients | Testimonials
My Forums: General Forums & Admin Talk





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

About Admin Addict
Admin Addict is community for forum admins and staff to interact and share ideas. Admin Addict is a newbie friendly community so even if your new to forums you will be welcome here.
Copyright © 2010-2012 Schwarz Network. All rights reserved.