Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2016, 05:26 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [SOLVED] If and or Condition

SOLVED:

save you some reading.
if anyone needs an if condition similar it turned out to be:
Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 AND ($vboptions[someOption] == 1 AND is_member_of($bbuserinfo, 6)))">

My if condition is currently as follows

Code:
<if condition="$show['registerbutton'] OR $vboptions[someOption] == 1">
im trying to make it an OR AND without doing an else so i dont have to repeat the code inside each block

kind of like

Code:
<if condition="$show['registerbutton'] OR $vboptions[someOption] == 1 AND $show['admin']">
so with the option off guests see it (well anyone who can see the register button can see it)

with the option on, guests can still see it but now only admins can too.

is this possible?
Reply With Quote
  #2  
Old 02-26-2016, 05:31 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use two ORs??...

Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 OR $show['admin'])">
Reply With Quote
  #3  
Old 02-26-2016, 05:39 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nhawk View Post
Use two ORs??...

Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 OR $show['admin'])">
that would not work

the option has to be on (1) in order for the admin to see it, if the option is off (0) then the admin wont see it but the guest (or people who can see the registerbutton) can still see it.

if i used 2 ORs the admin will always see it
Reply With Quote
  #4  
Old 02-26-2016, 05:41 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Easy enough. Is this closer to what you want?

Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 OR ($vboptions[someOption] == 1 AND $show['admin']))">
If not give each case of who can see what under what conditions.
Reply With Quote
  #5  
Old 02-26-2016, 05:45 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

one too many ORs in there but i gave it a shot like
Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 AND $show['admin'])">
but it didnt work =/
Reply With Quote
  #6  
Old 02-26-2016, 05:46 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dr.CustUmz View Post
one too many ORs in there but i gave it a shot like
Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 AND $show['admin'])">
but it didnt work =/
The other OR is needed with the code I posted.

Give exactly who should view what under what conditions.

To break it down..
Code:
<if condition="$show['registerbutton']  // SHOW IF TRUE
         OR ($vboptions[someOption] == 1 // SHOW TO THIS OPTION
         OR ($vboptions[someOption] == 1 AND $show['admin']))"> // SHOW IF BOTH THIS OPTION AND SHOW ADMIN ARE TRUE
Reply With Quote
  #7  
Old 02-26-2016, 05:51 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

option set to yes

GUEST and ADMIN view

FORUM HOME

REGISTER NOW


option set to no

GUEST view

FORUM HOME

REGISTER NOW



ADMIN view

none

registered members will never see it

--------------- Added [DATE]1456516446[/DATE] at [TIME]1456516446[/TIME] ---------------

Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 AND $show['admin'])">
im not seeing the missing )

but the code would be
Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 AND $show['admin'])">
 <DIV> BUTTON</DIV>
</if>
--------------- Added [DATE]1456516692[/DATE] at [TIME]1456516692[/TIME] ---------------

i used
Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 OR ($vboptions[someOption] == 1 AND $show['admin']))">
but normal members can still see the content...
Reply With Quote
  #8  
Old 02-26-2016, 06:06 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

IGNORE ORIGINAL POST
--------------- Added [DATE]1456517268[/DATE] at [TIME]1456517268[/TIME] ---------------

Quote:
Originally Posted by Dr.CustUmz View Post

i used
Code:
<if condition="$show['registerbutton'] OR ($vboptions[someOption] == 1 OR ($vboptions[someOption] == 1 AND $show['admin']))">
but normal members can still see the content...
OK, one of these is what you want then...
Code:
<if condition="$show['registerbutton'] AND ($vboptions[someOption] == 1 OR ($vboptions[someOption] == 1 AND $show['admin']))">
Code:
<if condition="$show['registerbutton'] AND (($vboptions[someOption] == 1 AND !$show['admin']) OR ($vboptions[someOption] == 1 AND $show['admin']))">
If neither on of those work, then I really don't understand what you're trying to do.
Reply With Quote
  #9  
Old 02-26-2016, 06:18 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

now guest cant see it if the option is off, and the admin cant see it at all =/
Reply With Quote
  #10  
Old 02-26-2016, 06:24 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is my product im working on if it will help you to see it and the way im trying to use it.

line 15 is where the if condition is

<if condition="$show['registerbutton'] OR ($vboptions[drc_rb_edt] == 1 OR ($vboptions[drc_rb_edt] == 1 AND $show['admin']))">

is what is currently in there, but this makes it so other members can see it also.

i always want guest to see it, then the admin to have an option to turn it on or off for themselves, not for everyone.
Attached Files
File Type: xml product-drcrb.xml (8.9 KB, 2 views)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:12 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05365 seconds
  • Memory Usage 2,278KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (15)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete