vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Little help with If condition (https://vborg.vbsupport.ru/showthread.php?t=270152)

qpurser 09-13-2011 12:08 AM

Little help with If condition
 
I am not that great with PHP coding and struggled with it for hours now but can't get it work.

I have a plugin that created a variable for a Category in my classifieds plugin:$catid
I want to show some text depending if the user is a member or not but only in a particular Category

What I am trying to do
If somebody looks up an item in
Category 3 and he is a member (usergroup= 9) it should say "Buy this item"
Category 3 and he is not a member (any usergroup besides 9) it should say "Members ONLY sale"

Any other category and no matter member or not it should say "Buy this item"

I tried this but didn't work

<vb:if condition="$catid == 3">
<vb:if condition="$vbulletin->userinfo[usergroupid] == 9">
<font color="#FFFFFF"><b></a>Buy this item</b></font>
<vb:if condition="$vbulletin->userinfo[usergroupid] <> 9">
<font color="#FFFF00"><b></a>Member ONLY sale</b></font>
</vb:if>
</vb:if>
</vb:if>

<vb:if condition="$catid <> 3">
<font color="#FFFFFF"><b></a>Buy this item</b></font>
</vb:if>

What am I doing wrong?
I got the hint on vbulletin.com to post here
Thanks for any help
Michael

nhawk 09-13-2011 10:49 AM

You have a mish mash of PHP and vB template script going on there.

Try this..
Code:

<vb:if condition="$catid == 3">
<vb:if condition="$bbuserinfo['usergroupid'] == 9">
<font color="#FFFFFF"><b></a>Buy this item</b></font>
<vb:else />
<font color="#FFFF00"><b></a>Member ONLY sale</b></font>
</vb:if>
<vb:else />
<font color="#FFFFFF"><b></a>Buy this item</b></font>
</vb:if>

And be sure that $catid is being passed to your template in the PHP code for your add-on. If it's not, it won't work.

qpurser 09-13-2011 12:39 PM

Thanks for the help.

This worked fine.

Maybe one more question regarding coding.

How would I program for example
if somebody does NOT belong to usergroup 9 AND 5 AND 3

Thanks

kh99 09-13-2011 01:46 PM

That would be:

Code:

<vb:if condition="!is_member_of($bbuserinfo, 9, 5, 3)">

</vb:if>



All times are GMT. The time now is 04:07 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.02071 seconds
  • Memory Usage 1,712KB
  • 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
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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