![]() |
|
Article Options |
Simplify your Template Conditionals
by
![]() If you want to be able to show/hide things in your templates based on Usergroups, you can either use something like:
or
...but if those usergroup ids ever change, or you want to add more groups to the array, it could get time consuming, especially if you have multiple styles. Wouldn't it be easier to be able to use:
? Well now you can! In includes/functions.php, find:
After, add
In adminfunctions_template.php find:
under, add:
Save and upload includes/functions.php and adminfunctions_template.php and you are done. You can now wrap
around whatever you want to show to people in Usergroups 9, 10 or 11...and if you need to add usergroup 12 to the list, all you need to do is add it in the function. Hoorah! No members have liked this post.
Last edited by kall; 06 Dec 2004 at 20:56.. |
||||||||||||||||||||||||||||||||
Views: 4666
|
Comments |
#2
|
||||
|
||||
ooo nice
![]()
__________________
My Site:Animation Talk My Hacks:Vb3 Affiliate Version 1:vB Affiliates v.2:vB Journal 1.0.0:Quick Attachment Approval System: UnBannable Ips:Text Message on PM:Selected Files Not Closed:New Thread/Post Image Verification for Guests: vB Stocks 1.0.0 This means this hack won an award. No members have liked this post.
|
#3
|
||||
|
||||
I feel confident when I say this won't work right away....I think
![]() I only saw this when looking through vB files that there's some array of safe functions that the template parses, and it ignores everything else... I might be wrong, so dont shoot me! ![]() No members have liked this post.
|
#4
|
||||
|
||||
Your thread title doesn't really simplify all template conditionals as it would imply. Something along the lines of 'Easy template conditional to select users from particular usergroups'. Thanks for releasing btw
![]()
__________________
Dean Clatworthy - Web Developer/Designer No members have liked this post.
|
#5
|
||||
|
||||
Good idea, but you can simplify it even more by adding it as an Admin CP Options settings variable.
![]() Because if you think changing a template is a pain when you want to add usergroups, at least you can do it anywhere. Changing a PHP file to add usergroups is much harder. ![]() You're better off adding the group in your phpinclude_start template - e.g. $specialgroupid = "1,2,3,4,5"; Then using that anywhere in your templates: <if condition="in_array($bbuserinfo[usergroupid], array($specialgroupid))"> Then just change the numbers in your phpinclude_start template anytime. ![]() No members have liked this post.
|
#6
|
||||
|
||||
Originally Posted by Revan
Oopsie. You're right...I realised this as I was falling asleep last night. adminfunctions_template.php needs an edit too.
![]() Sorted. @Dean: I know...I'm crap at descriptive titles that don't run the length of 2 pages. ![]()
__________________
vBulletin Styles (All styles compatible with 3.8.4 - Steel Blue 4.0 Available) | vBulletin Hosting No members have liked this post.
|
#7
|
||||
|
||||
Really nice! I was wondering how to do this a while back!
/me installs ![]() No members have liked this post.
|
#8
|
||||
|
||||
this thread was of some use. Thanks.
No members have liked this post.
|
![]() |
«
Previous Article
|
Next Article
»
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Article Options | |
|
|
New To Site? | Need Help? |
All times are GMT. The time now is 21:21.