View Single Post
  #4  
Old 09-08-2002, 05:20 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Conditionals Help

If you are using my WebTemplates Hack or Dynamic Announcements: Programmable Forum Home Announcement/Message with conditionals Hack, this hack's conditionals are exactly same with these hacks'.

Here is the conditional syntax: (it's strict in syntax so please apply correctly!)
[[(your conditional)]]
HTML code posted in template if condition applies
[[/(your conditional)]]

Conditional Rules:

* Conditionals are covered inside [[ ]] tags
* Conditional (both opening and closing) itself is in paranthesis ( )
* HTML codes are written in between the conditional tags and they are displayed in the template if condition applies
* Opening and closing conditional are exactly same except closing conditional has a / right before (
* If you are trying to check if X equals to Y, use DOUBLE equation mark not single. eg. Correct: X==Y Incorrect:X=Y
* You can design as many conditional as you like. If more than 1 condition applies at the same time, ALL applying conditionals HTML codes are parsed and all not-applied conditionals and their HTML code is automatically deleted when template is displayed.

Some examples will help you understand the rules better. Here are some conditionals and their instruction texts which explains what that conditional do: (Consider HTML codes is in between instead of instruction texts and they are parsed if condition applies)

* [[($bbuserinfo[userid]==32)]] Display this HTML code if page visitor's user id is 32 [[/($bbuserinfo[userid]==32)]]

* [[($bbuserinfo[usergroupid]==5)]] Display this HTML code if page visitor's usergroupid is 5 (=if he is a Super Mod) [[/($bbuserinfo[usergroupid]==5)]]

* [[($bbuserinfo[usergroupid]==1)]] Display this HTML code if page visitor is a guest [[/($bbuserinfo[usergroupid]==1)]]

* [[($bbuserinfo[userid]>1)]] Display this HTML code if page visitor is NOT a guest [[/($bbuserinfo[userid]>1)]]

* [[($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==7)]] Display this HTML code if page visitor's a Super Mod OR a Mod OR an Admin [[/($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==7)]]

* [[($bbuserinfo[posts]<10)]] Display this HTML code if page visitor has less than 10 posts [[/($bbuserinfo[posts]<10)]]

* [[($bbuserinfo[lastvisit] and $bbuserinfo[lastvisit]<strtotime("-30 days"))]]Display this HTML code if page visitor has not visited your board for 30 days[[/($bbuserinfo[lastvisit] and $bbuserinfo[lastvisit]<strtotime("-30 days"))]]

* [[($bbuserinfo[joindate]>strtotime("-2 weeks") AND $bbuserinfo[joindate]<strtotime("-4 weeks"))]]Display this HTML code if page visitor registered in a date between 2 weeks to 4 weeks from now[[/($bbuserinfo[joindate]>strtotime("-2 weeks") AND $bbuserinfo[joindate]<strtotime("-4 weeks"))]]

You can use conditionals together too. Here is an example:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[[($bbuserinfo[userid]==32)]] HTML Codes 1[[/($bbuserinfo[userid]==32)]]
[[($bbuserinfo[usergroupid]==3)]] HTML Codes 2 [[/($bbuserinfo[usergroupid]==3)]]
HTML Codes 3
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
When this template is called the hack will :
Display HTML Codes 1, if user's userid = 32
Display HTML Codes 2, if user's usergroupid = 3 (=email confirmation waiting members)
and always display HTML Codes 3 (it's out of conditionals)

What if user 32 is also from user groupid 3? He will be BOTH displayed HTML Code 1 AND 2 because both conditionals are parsed if they applies.

Another example of how you can design a multi-template:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[[($bbuserinfo[posts]<30)]]

<Your Templates default HTML Code here >

[[/($bbuserinfo[posts]<30)]]
[[(!($bbuserinfo[posts]<30))]]

You dont have permission to access this page!

[[/(!($bbuserinfo[posts]<30))]]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
When you use this code in any of your template, if page visitor's post number is less than 30, he will be displayed "You dont have permission to access this page!" but any other users will see the template.

My Support for this hack: Just like all my other hacks I support this hack for any installation problems, bugs etc. (very unlikely there will be any) but as you would hopefully understand it's impossible for me to support the hack about forming your "conditionals". I give you detailed how-to instructions and samples and but there can be thousands of conditional designs people might ask for and it's not possible for me to answer all the time one by one. I dont discourage you to ask them away here in this thread so be my guest if you need help, but please forgive me if I cant personally answer you about these requests and I hope that other hack users will help out in the thread for these requests.. (While asking it can help if you give your failed samples).. Thanks for understanding..
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01187 seconds
  • Memory Usage 1,793KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete