Log in

View Full Version : mysql & conditionals


harmor19
01-11-2006, 11:05 PM
I have a row named "view_link" varchar(2) not null.

I'm using the conditional
<if condition="is_member_of($bbuserinfo, $dlink['view_link'])">

If I make the value for "$dlink['view_link']" to "6" then I can see the link.
If I make it "1,6,3" I cannot see it.

TyleR
01-11-2006, 11:09 PM
<if condition="in_array($bbuserinfo[usergroupid], array(1,6,3))">..</if>

Not exactly sure if the array() function is allowed in templates, but am sure it is.

harmor19
01-11-2006, 11:10 PM
I'll try that.

It's weird because I did.. and it worked out fine but doesn't work with mysql.
<if condition="is_member_of($bbuserinfo, 1,6)">

Edit:
The only time it works with mysql if I only use one number such as "6"
If I were to use multiple numbers then it won't work "1,4,6"

TyleR
01-11-2006, 11:17 PM
Hmm..try doing it with the is_member_of function, i.e.:

<if condition="is_member_of($bbuserinfo, array(1,6,3))">..</if>

harmor19
01-11-2006, 11:22 PM
It still only works with one number as the value.

Why couldn't this be simple?
Now I have to find something that does it similiar to how I want to do it and do all this work.
I think there's a hack where I can choose which forums I want something to into.

Guest190829
01-11-2006, 11:31 PM
I think it has to do with your column type, try setting it to something like varchar(20) rather then varchar(2)....

/me isn't a genious at columns types though...

harmor19
01-11-2006, 11:34 PM
Still no luck..

Edit:
I'm not at home but I may have found something that will work.

<?php

$member_of = "1,3,6";

$usergroup = array($member_of);
$array = implode(",", $usergroup);

echo $array;

<if condition="is_member_of($bbuserinfo, array($array))">..</if>

?>

Hopefully this will work with mysql.

harmor19
01-13-2006, 12:04 AM
can I bump this?

I don't understand why it doesn't work.

If you want my whole plugin ask for it and I'll upload it.

Edit:
Here's the part to display stand-alone links

$getsinglelinks = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "custom_singlelinks WHERE linkid");

while($slink = $db->fetch_array($getsinglelinks))
{
if($slink['new_window'] == 1)
{
$new = "_blank";
}
else
{
$new = "";
}

if(!empty($slink['image']))
{
$img = "<img src='".$slink['image']."' width='16' height='16' />";
}
else
{
$img = "";
}

$usergroup = array($slink['member_of']);
$array = implode(",", $usergroup);


$custom_singlelinks .= "<if condition='is_member_of($bbuserinfo, array($array))'><td class='vbmenu_control'>$img<a href='".$slink['url']."' target='$new' title='".$slink['alt']."'>".$slink['name']."</a></td></if>";

eval('$custom_singlelinks = "' . fetch_template('custom_singlelinks') . '";');
}

Deviation
01-13-2006, 04:10 PM
What is $slink['member_of'] stored in the DB as (format & type)? I don't think you can pass is_member_of an array() in the templates. At least not via the PHP array() function. Not 100% sure on that though (not home to verify it).

Electronic Punk
01-19-2006, 10:49 AM
Yeah, I was also wondering if is_member_of could be used to specify mutliple membergroups, can't really add the statement 4 times because some people could end up with 4 times the code if they don't meet any of th e requirements.

What syntax should I use for an or statement?

condition="!is_member_of($bbuserinfo, 11)" || condition="!is_member_of($bbuserinfo, 5)"

does not seem to work.