PDA

View Full Version : Please take a second and help me with this if conditional


DieselMinded
06-22-2010, 10:58 PM
Why Wont this work?
<if condition="$bbuserinfo[field15] == 'YES">
<if condition="THIS_SCRIPT != 'chat.php">
<if condition="is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if></if></if>

--------------- Added 1277251795 at 1277251795 ---------------

How about this ??

<if condition="$bbuserinfo[field15] == 'YES' AND "THIS_SCRIPT != 'chat.php' AND "is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">STUFF</if>

will that work?

KevinL
06-22-2010, 11:25 PM
Maybe this?


<if condition="$bbuserinfo[field15] == '15'">
<if condition="THIS_SCRIPT != 'chat'">
<if condition="is_member_of($vbulletin->userinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if></if></if>


--------------- Added 1277253035 at 1277253035 ---------------

No maybe this...


<if condition="$bbuserinfo[field15] == '15'">
<if condition="THIS_SCRIPT == 'chat'">
<if condition="is_member_of($vbulletin->userinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if></if></if>

DieselMinded
06-22-2010, 11:38 PM
Neither worked

KevinL
06-22-2010, 11:46 PM
What if you got rid of the THIS_SCRIPT?


<if condition="$bbuserinfo[field15] == 'YES'">
<if condition="is_member_of($vbulletin->userinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if></if>


hmmm

DieselMinded
06-22-2010, 11:55 PM
whole thing goes away , and yes i have field15 set to yes on my profile :D

Boofo
06-23-2010, 12:03 AM
Check the field15 and see if yes is set as all caps. It needs to be EXACTLY as you entered it in the profile field setup.

DieselMinded
06-23-2010, 12:11 AM
I went and toggled profile field 15 to no , then yes and it appears to be working with

<if condition="$bbuserinfo[field15] == 'Yes'">
<if condition="is_member_of($vbulletin->userinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if></if>

But why did i have to toggle it?

--------------- Added 1277255751 at 1277255751 ---------------

even tho its Yes at default you have to go to edit options and hit save for it to show how can i fix that?

noppid
06-23-2010, 12:17 AM
Did you create the custom field in the acp? If so, you are looking for an integer, not text.

DieselMinded
06-23-2010, 12:20 AM
Yes i created the profile field in the admin cp , what do i need to do to get this on track , i got it working but you have to go to edit options and hit save for it to take , and still cant figure out how to keep it off chat.php

KevinL
06-23-2010, 12:22 AM
Well I had that in my first ones...and he said it didn't work. Maybe if he tries one of the first ones I said and took out THIS_SCRIPT part?

noppid
06-23-2010, 12:24 AM
Do a view source on your profile page where you select the option. See if yes is 0, 1 or 2 or whatever depending on your settings. each input will have a label and a value.

What type field is it, radio or menu?

DieselMinded
06-23-2010, 12:26 AM
It is radio - Yes No

Here is the source

<fieldset class="fieldset">
<legend>Enable Cometchat Software?</legend>
<table cellpadding="0" cellspacing="3" border="0" width="100%">

<tr>
<td>If you are a Premium Member, Sponsor or Staff, You Can Use the Cometchat Software. It Adds a Bar to the bottom of the page and allows you to instantly chat with other users. Click YES if you want to use it or NO if you do not want to use it.</td>
</tr>
<tr>
<td>
<table cellpadding="2" cellspacing="0" border="0">
<tr><td valign="top"><label for="rb_cpf_field15_1"><input type="radio" name="userfield[field15]" value="1" id="rb_cpf_field15_1" checked="checked" />Yes</label></td><td valign="top"><label for="rb_cpf_field15_2"><input type="radio" name="userfield[field15]" value="2" id="rb_cpf_field15_2" />No</label></td></tr>

</table>
<input type="hidden" name="userfield[field15_set]" value="1" />
</td>
</tr>

</table>
</fieldset>

noppid
06-23-2010, 12:30 AM
<if condition="$bbuserinfo[field15] == 1 AND THIS_SCRIPT != 'chat.php' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>



If field 15 is yes, and the script is NOT chat.php, and the member is in these groups.

Of course chat.php must have define('THIS_SCRIPT', 'chat.php'); in it.

KevinL
06-23-2010, 12:33 AM
<if condition="$bbuserinfo[field15] == '1'">
<if condition="THIS_SCRIPT != 'chat'">
<if condition="is_member_of($vbulletin->userinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if></if></if>

Also make sure that the cometchat is actually defined as 'chat' otherwise you have to change that to what ever it is defined as.

If you get rid of that line then it will be on all pages


EDIT:

Or use his it is cleaner :p

DieselMinded
06-23-2010, 12:33 AM
its not showing at all even with a visit to the edit options page and hitting save

--------------- Added 1277256898 at 1277256898 ---------------

the chat that im not showing the Cometchat on is the Addonchat page , VBSEO is not showing on the Chat Page with chat.php added to the exclude list so chat.php must be the script

noppid
06-23-2010, 12:36 AM
The condition is set to this in post 13...

If field 15 is yes, and the script is NOT chat.php, and the member is in these groups.

Of course chat.php must have define('THIS_SCRIPT', 'chat.php'); in it.

DieselMinded
06-23-2010, 12:37 AM
<if condition="$bbuserinfo[field15] == 1 AND THIS_SCRIPT != 'chat.php' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>



If field 15 is yes, and the script is NOT chat.php, and the member is in these groups.

Of course chat.php must have define('THIS_SCRIPT', 'chat.php'); in it.

Thats EXACTLY what im looking for but its not showing up at all with this code

--------------- Added 1277257193 at 1277257193 ---------------

chat.php has

define('THIS_SCRIPT','chat');

in it

noppid
06-23-2010, 12:40 AM
P.S. I'm not so sure about those paths to the css and js either. Make sure they are correct in view source. See if they show at all in the view source. It may be there but not working due to a bad path.

Do this then for the chat condition....


<if condition="$bbuserinfo[field15] == 1 AND THIS_SCRIPT != 'chat' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>

DieselMinded
06-23-2010, 12:43 AM
Im sorry but nothing is showing for

<if condition="$bbuserinfo[field15] == 1 AND THIS_SCRIPT != 'chat.php' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">STUFF</if>

Please dont give up

noppid
06-23-2010, 12:45 AM
OK, update to the code in post 18 to fix the chat part.

Then go to a page the code should run on and view source. See if you can find: <!-- CometChat Footer Code Start -->

If it's there, the condition is working, but the css and js paths are wrong as I suspect perhaps. Post the code you see so we can review those paths?

Where is the cometchat folder on your site?

If you have to, echo out the custom field by putting this in the template..

Field15 = $bbuserinfo[field15]<br />

DieselMinded
06-23-2010, 12:50 AM
cometchat folder is on root dir

Header of site has
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>jqcc=jQuery.noConflict(true);</script>
at the top

and footer has
<if condition="$bbuserinfo[field15] == 1 AND THIS_SCRIPT != 'chat' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>
at the bottom

dont see footer code on page source

noppid
06-23-2010, 12:55 AM
echo out the custom field by putting this in the template..

Field15 = $bbuserinfo[field15]<br />

See if you can find that in the source code view.

DieselMinded
06-23-2010, 12:57 AM
like put

Field15 = $bbuserinfo[field15]<br />

at the bottom of the forum home?

noppid
06-23-2010, 01:00 AM
like put

Field15 = $bbuserinfo[field15]<br />

at the bottom of the forum home?

correct.

DieselMinded
06-23-2010, 01:03 AM
well ill try that right now but fyi with

<if condition="THIS_SCRIPT != 'chat' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>

i got the bar back and its showing to the right people but its showing on the chat page still


Ill change it back and run your test

--------------- Added 1277258861 at 1277258861 ---------------

Footer now has

<if condition="$bbuserinfo[field15] == 1 AND THIS_SCRIPT != 'chat' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>
Field15 = $bbuserinfo[field15]<br />

in it and the source code is...

Field15 = Yes<br /><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1620004-1";
urchinTracker();

noppid
06-23-2010, 01:11 AM
OK, the answer is being parsed to how you spelled Yes when creating the field.

So, I blew it. Try this...


<if condition="$bbuserinfo[field15] == 'Yes' AND THIS_SCRIPT != 'chat' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>

Boofo
06-23-2010, 01:16 AM
I went and toggled profile field 15 to no , then yes and it appears to be working with

<if condition="$bbuserinfo[field15] == 'Yes'">
<if condition="is_member_of($vbulletin->userinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if></if>

But why did i have to toggle it?

--------------- Added 1277255751 at 1277255751 ---------------

even tho its Yes at default you have to go to edit options and hit save for it to show how can i fix that?
Didn't you change YES to Yes? ;)

DieselMinded
06-23-2010, 01:24 AM
THANK YOU THANK YOU !

i also surrounded the header code in the conditional to keep if from loading when it wasnt needed

the final answer was

<if condition="$bbuserinfo[field15] == 'Yes' AND THIS_SCRIPT != 'addonchat' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">STUFF</if>

noppid Please PM me your pay pal for a donation

noppid
06-23-2010, 01:28 AM
Glad to help. Sorry it took so long. I forgot about the parsing of the options, but remembered the form.

DieselMinded
06-23-2010, 01:48 AM
Thanks Again $ Sent , More people should donate to people who help them and maybe more people would help others on here

noppid
06-23-2010, 01:50 AM
Very generous. Thank you.

ChopSuey
06-23-2010, 04:12 PM
Thanks Again $ Sent , More people should donate to people who help them and maybe more people would help others on here
Just thinkg about how many people i and other's have helped.

noppid
06-23-2010, 04:31 PM
Right on, that's what this site is supposed to be about. I don't post here for the money. It's just something to do to pay it forward. That's not to say I don't do professional work though. I'm picky about who I work with either way. Some appreciate it and you can tell, others, not so much.

DieselMinded
06-23-2010, 09:24 PM
Works great but users still have to go to there edit options and hit save for the bar to show , how can i fix that?

noppid
06-23-2010, 10:04 PM
We need to look at which of the options is the default. Look in the user profile field editor and check the "Set Default" options for that custom field.

I don't know how it works code wise, hopefully it will update all users to the default when changed. The worse case scenario is having to delete it and create it again with a default which will hopefully set the default in their profile and not just the form.

DieselMinded
06-23-2010, 10:06 PM
Default is yes , its showing clicked , all they do is hit save

noppid
06-23-2010, 10:09 PM
So it is for the form only and not the actual setting in the DB for each user? It's actually no unless they go click? I didn't mock it up for a test, so I don't know what it's doing code wise.

DieselMinded
06-23-2010, 10:15 PM
User Profile Fields in Area: Options: Messaging / Notification

Enable Cometchat Software? Single-Selection Radio Buttons Editable, Searchable field15

--------------- Added 1277334972 at 1277334972 ---------------

Do i need to move if from edit options ? maybe it don't autoupdate or something

Maybe <if condition="$bbuserinfo['field15'] != 'No' ">

noppid
06-23-2010, 10:21 PM
I went in the DB with PHPMyAdmin. Seems like it's gonna take a query to pull off. This will opt everyone in as Yes and they will have to go to the cp to turn it to no instead of Yes.

Here's a query you can run in PHPMyAdmin from the SQL tab...

update `userfield` set `field15` = 'Yes' where `field15` = '';

If you have table prefixes, adjust the userfield table name. Take note of backtics and single quote usage in the query.

--------------- Added 1277335389 at 1277335389 ---------------

User Profile Fields in Area: Options: Messaging / Notification

Enable Cometchat Software? Single-Selection Radio Buttons Editable, Searchable field15

--------------- Added 1277334972 at 1277334972 ---------------

Do i need to move if from edit options ? maybe it don't autoupdate or something

Maybe <if condition="$bbuserinfo['field15'] != 'No' ">

Changing the condition to No won't help. The DB has empty fields.

DieselMinded
06-23-2010, 10:26 PM
testing

<if condition="$bbuserinfo[field15] != 'No' AND THIS_SCRIPT != 'addonchat' AND is_member_of($bbuserinfo, 5, 7, 6, 16, 12, 11, 17, 10, 13, 9)">
<!-- CometChat Footer Code Start -->
<link type="text/css" rel="stylesheet" media="all" href="/cometchat/cometchatcss.php" charset="utf-8" />
<script type="text/javascript" src="/cometchat/cometchatjs.php" charset="utf-8"></script>
<!-- CometChat Footer Code End -->
</if>

--------------- Added 1277335715 at 1277335715 ---------------

I went in the DB with PHPMyAdmin. Seems like it's gonna take a query to pull off. This will opt everyone in as Yes and they will have to go to the cp to turn it to no instead of Yes.

Here's a query you can run in PHPMyAdmin from the SQL tab...

update `userfield` set `field15` = 'Yes' where `field15` = '';

If you have table prefixes, adjust the userfield table name. Take note of backtics and single quote usage in the query.

--------------- Added 1277335389 at 1277335389 ---------------



Changing the condition to No won't help. The DB has empty fields.

what about future members?

noppid
06-23-2010, 10:32 PM
Look at "Field Required" in edit custom profile fields. You can force it onto the registration template.

DieselMinded
06-23-2010, 10:36 PM
regular members cant use it anyway.

there has to be a way that new supporters dont have to go to edit options and hit save for it to show.

its already on YES by default so it should show , must be some sort of bug for the page to need saved or something

noppid
06-23-2010, 10:44 PM
regular members cant use it anyway.

there has to be a way that new supporters dont have to go to edit options and hit save for it to show.

its already on YES by default so it should show , must be some sort of bug for the page to need saved or something

What you are misunderstanding is that it is set to display Yes as the default only on the form. It does not set the default as Yes for the members, it stays blank in the DB until an action by the member is taken.

If this involves members in a particular group, a profile field my not e the best way to approach this. The plot thickens.

DieselMinded
06-23-2010, 11:08 PM
well if they want to use it they can click save ... :D

noppid
06-23-2010, 11:28 PM
If you decide to put it in the registration, you are still covered by your group code. But running the query will be the key to the current users. Set it to required and I think they get told to go take an action. Can't remember.