Log in

View Full Version : Need a conditional please?


bashy
10-20-2006, 08:31 PM
Hi peeps

I have this code to show some rotating banners/ads

<p align="center">
<SCRIPT LANGUAGE="Javascript"><!--
function banner() {
};
banner = new banner();
number = 0;

// bannerArray
banner[number++] = "<a href='https://www.hosting.bashys-place.com' target='_blank'><img src='http://www.bashys-place.com/images/bashyshosting.jpg' border='1'></a>"
banner[number++] = "<a href='https://www.hosting.bashys-place.com' target='_blank'><img src='http://www.bashys-place.com/images/webhosting.gif' border='1'></a>"
banner[number++] = "<a href='https://www.hosting.bashys-place.com' target='_blank'><img src='http://www.bashys-place.com/images/bashyshosting.jpg' border='1'></a>"
banner[number++] = "<a href='https://www.hosting.bashys-place.com' target='_blank'><img src='http://www.bashys-place.com/images/webhosting.gif' border='1'></a>"
banner[number++] = "<a href='http://www.credit-busters.co.uk' target='_blank'><img src='http://www.bashys-place.com/images/credit.gif' border='1'></a>"


increment = Math.floor(Math.random() * number);
document.write(banner[increment]);
//--></SCRIPT>
<br />
<font color="#008000"><b><br>If you wish to advertise here?<br>Please </b></font>
<b><a href="http://www.bashys-place.com/forums/advertise.php">
<font color="#FF0000"><span style="background-color: #FFFF00">View this page</span></font></a></b></p>

Basically, this is shown to all, including guests, I want this so that 1 of my usergroups (VIP) cannot see it and see something else instead.

Can anyone advise please

peterska2
10-20-2006, 10:39 PM
you would then want to put<if condition="is_member_of($user, usergroup id number of your VIP group eg 17)">
The stuff you want your VIP's to see
<else />
before your code and then at the end of your code add</if>

bashy
10-21-2006, 02:59 PM
Thanks KA will try this :)

bashy
10-30-2006, 05:25 PM
Hi KA

How would i create a conditional for 1 or multiple members then?

example:

We have the Moderator Application system installed, We have 1 or 2 members that are repeatedly filling in the application, i would therefore like to be able to add there user ID's to the condtional for the link in the quick links menu, i just aint sure as to the condional to use?

Adrian Schneider
10-30-2006, 05:32 PM
Where the userIDs are 1 2 and 3:<if condition="in_array($vbulletin->userinfo['userid'], array(1, 2, 3))">...</if>If you want to check for these userIDs OR staff members, you can use do so <if condition="is_member_of($vbulletin->userinfo, 5, 6, 7) or in_array($vbulletin->userinfo['userid'], array(1, 2, 3))">

For your own sanity down the road, I would actually suggest this: global_start$moderator_usergroups = array(5, 6, 7);
$moderator_users = array(1, 2, 3);

$show['moderator_app_links'] = (
is_member_of($vbulletin->userinfo, $moderator_usergroups) or
in_array($vbulletin->userinfo['userid'], $moderator_users)
);Then use <if condition="$show['moderator_app_links']">in your template because it will be easier to manage without digging through your templates.

bashy
10-30-2006, 05:40 PM
Hi Sir :)

Thannks, i will have a good read of these and see whats what, thanks again :)

I take it thats a plugin to create?
then just update it as and when?

Adrian Schneider
10-30-2006, 05:52 PM
Yeah it's a plugin. I'm not sure I understand your question though...

bashy
10-30-2006, 05:59 PM
I meant just update it with each user that i dont want to see the link?

Actually i have just tried this and the user in question can still see and click the link
heres what i have in the template
<if condition="$show['moderator_app_links']" <tr><td class="vbmenu_option"><a href="$vboptions[bburl]/modapp.php?$session[sessionurl]">Apply To Be A Mod</a></td></tr></if>

and the plugin i only changed the user ID to 9

$moderator_usergroups = array(5, 6, 7);
$moderator_users = array(9);

$show['moderator_app_links'] = (
is_member_of($vbulletin->userinfo, $moderator_usergroups) or
in_array($vbulletin->userinfo['userid'], $moderator_users)
);

Ah....just realised, this is the wrong way round, where i have user ID 9 this is the user ID that i DONT want to be able to see the link, allthe rest can see, but as it is atm is that is the only user apart from the staff that can see it lol
What do i do to turn it round please?

Adrian Schneider
10-30-2006, 06:24 PM
lol $moderator_usergroups = array(5, 6, 7);
$ignore_users = array(9);

$show['moderator_app_links'] = (
is_member_of($vbulletin->userinfo, $moderator_usergroups) and
!in_array($vbulletin->userinfo['userid'], $ignore_users)
);

-edit fixed my typo

bashy
10-30-2006, 06:30 PM
Thats the 1 m8, thank you very much for your help!! :)