vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   [SOLVED] If and or Condition (https://vborg.vbsupport.ru/showthread.php?t=321930)

Dr.CustUmz 02-26-2016 05:26 PM

[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?

nhawk 02-26-2016 05:31 PM

Use two ORs??...

Code:

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

Dr.CustUmz 02-26-2016 05:39 PM

Quote:

Originally Posted by nhawk (Post 2565661)
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

nhawk 02-26-2016 05:41 PM

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.

Dr.CustUmz 02-26-2016 05:45 PM

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 =/

nhawk 02-26-2016 05:46 PM

Quote:

Originally Posted by Dr.CustUmz (Post 2565664)
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


Dr.CustUmz 02-26-2016 05:51 PM

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...

nhawk 02-26-2016 06:06 PM

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

Quote:

Originally Posted by Dr.CustUmz (Post 2565667)

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.

Dr.CustUmz 02-26-2016 06:18 PM

now guest cant see it if the option is off, and the admin cant see it at all =/

Dr.CustUmz 02-26-2016 06:24 PM

1 Attachment(s)
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.


All times are GMT. The time now is 01:49 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.01716 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (15)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete