vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Conditional Statement Help (https://vborg.vbsupport.ru/showthread.php?t=171059)

MrEyes 02-20-2008 09:44 PM

Conditional Statement Help
 
I am attempting to write a conditional statement for the header template, in plain english it would be:

if ("script == showthread" and "User Logged On" and "Thread Age > 30 Days") OR (forum ID == 33)
{
..output something
}
else if (no user logged on)
{
..output something
}

Now my stab at this is:

<if condition="in_array(THIS_SCRIPT, array(showthread)) AND $bbuserinfo['userid'] != 0 AND $threadinfo['dateline'] < (TIMENOW - 2419200) OR $forumid == 33">
..output something
<else />
<if condition="$bbuserinfo['userid'] == 0">
..output something
</if>
</if>

However this just doesnt seem to work right, and I can't see where

Opserty 02-21-2008 11:27 AM

Code:

<if condition="((THIS_SCRIPT == 'showthread') AND ($show['member']) AND ($threadinfo['dateline'] < (TIMENOW - 2419200))) OR $forumid == 33">
    output something
<else />
    <if condition="$show['member']">
        output something
    </if>
</if>

If it doesn't work, take out the different conditions bit by bit and find which is causing the problem.

cheesegrits 02-21-2008 04:17 PM

You are missing a closing parenthesis. Probably needs to before the OR.

-- hugh

Opserty 02-21-2008 04:47 PM

Whoops, nice spot.

(Edited my post too)

cheesegrits 02-21-2008 07:44 PM

I'm surprised the template compiler didn't barf when MrEyes saved that one. I would expect it to throw an error and do the "go back and fix the error, or continue regardless" thing.

-- hugh

Opserty 02-21-2008 08:03 PM

It doesn't really check the contents of the condition except to check function calls, only that the <if> tags are opened/closed correctly.

MrEyes 02-23-2008 07:01 PM

Thanks for that, it works perfectly

Well after a minor edit :) I had to change

<else />
<if condition="$show['member']">
output something
</if>
</if>

to

<else />
<if condition="!$show['member']">
output something
</if>
</if>

for that condition to be hit by logged out users

GameWizard 02-26-2008 10:49 AM

Although this is correct:
Code:

<if condition="!$show['member']">
You can also use this:
Code:

<if condition="$show['guest']">
Same result.


All times are GMT. The time now is 09: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.01049 seconds
  • Memory Usage 1,721KB
  • 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
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete