Simplify your Template Conditionals
If you want to be able to show/hide things in your templates based on Usergroups, you can either use something like:
Code:
<if condition="$bbuserinfo['usergroupid'] == '9' || $bbuserinfo['usergroupid'] == '10' || $bbuserinfo['usergroupid'] == '11'"> Code:
<if condition="in_array($bbuserinfo[usergroupid], array(9,10,11))"> Wouldn't it be easier to be able to use: Code:
<if condition="is_paid_member()"> Well now you can! In includes/functions.php, find: PHP Code:
PHP Code:
PHP Code:
PHP Code:
Save and upload includes/functions.php and adminfunctions_template.php and you are done. You can now wrap Code:
<if condition="is_paid_member()"></if> Hoorah! |
ooo nice:)
|
I feel confident when I say this won't work right away....I think :p
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! ;) |
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 :)
|
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. :) |
Quote:
Sorted. @Dean: I know...I'm crap at descriptive titles that don't run the length of 2 pages. :) 'Add new Usergroup Macros for Template Conditionals' was one I played with. Feel free to edit the title to something a bit better. |
Really nice! I was wondering how to do this a while back!
[high]* Koutaru installs :)[/high] |
this thread was of some use. Thanks.
|
All times are GMT. The time now is 09:05 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|