Helpful Information
 
 
Category: vBulletin 4 Articles
vB4 Template Conditionals List

I put this together because it seems lots of people are having problems with the new syntax for conditionals.

First off remember you can not use {vb:raw var} in template conditionals.

Show only members:
<vb:if condition="$show['member']">Show this to members only</vb:if>


Show only guest:
<vb:if condition="$show['guest']">Show this to guest only</vb:if>


Show specific user groups :
<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</vb:if>


Show one member:
<vb:if condition="$bbuserinfo['userid'] == 318713">Show this only to the member with the user id of 318713</vb:if>


Show every one but one member:
<vb:if condition="$bbuserinfo['userid'] != 318713">Show this to every one but the member with the user id of 318713</vb:if>


Show only moderators of any forum:
<vb:if condition="can_moderate()">Show this to all moderators</vb:if>

Show Moderator of one forum: Remember to change x
<vb:if condition="can_moderate($forum['x])">Show this if moderator is moderator of the forum with the id of x</vb:if>


Show Moderator of current forum:
<vb:if condition="can_moderate($forum['forumid'])">Show this to the moderator of the current forum</vb:if>


Show in one forum: Remember to change x
<vb:if condition="$forum[forumid] == x">Show this if forum id is x</vb:if>


Show is every forum but one: Remember to change x
<vb:if condition="$forum[forumid] != x">Show this if forum id is not x</vb:if>


Show in several forums:
<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>


Show in only one file: Look for define('THIS_SCRIPT', 'calendar'); in the top of the php file you want it to show in.
<vb:if condition="THIS_SCRIPT == 'calendar'">Show this only on calendar.php</vb:if>


Show in every file but one: Look for define('THIS_SCRIPT', 'calendar'); in the top of the php file you do not want it to show in.
<vb:if condition="THIS_SCRIPT != 'calendar'">Show this only on calendar.php</vb:if>


If $customvar is set:
<vb:if condition="$customvar">Show this if $customvar is set</vb:if>


If $customvar equals:
<vb:if condition="$customvar == blah">Show this if $customvar equals blah</vb:if>


If $customvar does not equal:
<vb:if condition="$customvar != blah">Show this if $customvar does not equal blah</vb:if>


vBulletin else statement:

<vb:if condition="$show['guest']">
Show this to only guest.
<vb:else />
Show this to all registered users
</vb:if>



vBulletin else if statement:

<vb:if condition="$show['guest']">
Show this to only guest.

<vb:elseif condition="is_member_of($bbuserinfo, 5,6)" />
Show this to user group 5 and 6 which is mods and admins

<vb:else />
Show this to all registered users

</vb:if>



This is all that I can think of right now off the top of my head.
Please feel free to add any I forgot and I will add them to this list and give you credit.

subscribed!

Thanks for this list! :)

Excuse me a question, to the undersigned not work conditions with $forum[forumid] is the variable that changed?

thanks


PS example

<vb:if condition="!in_array($forum[forumid], array(18,19))">

text text

</vb:if>

very nice, this has helped me understand all the conditionals much better.

subscribe too..

nice, thx u

this is so clutch...nice

super, thanks & happy new yeahr ;)

thank you very much

Excuse me a question, to the undersigned not work conditions with $forum[forumid] is the variable that changed?

thanks


PS example

<vb:if condition="!in_array($forum[forumid], array(18,19))">

text text

</vb:if>
$forum[forumid] have to be registered to the template.
There's an other article here.

$forum[forumid] have to be registered to the template.
There's an other article here.

thanks, I must enter the new logic. Happy New Year

Hi - thanks for this post, however, can you provide conditionals for CMS sections please?

Hi - thanks for this post, however, can you provide conditionals for CMS sections please?

I don't have the CMS and most of these will work for the CMS.

You may have to preregister the var.

Thanks

Hello everybody! I have one problem with porting one of my products to VB4.

I have the setting for a product called vfsms_can_stick_by_sms - it's comma separated list of forum-sections where this product is turned on.

In this product I have the following plugin:


<plugin active="1" executionorder="5">
<title>Detecting can thread in this forum can be stick up by SMS or not.</title>
<hookname>showthread_start</hookname>
<phpcode>
<![CDATA[
$vfsms_can_stick_by_sms_forums_ids = str_replace(' ', '', $vbulletin->options['vfsms_can_stick_by_sms']);
$vfsms_allowed4sticky_forums = explode(',', $vfsms_can_stick_by_sms_forums_ids);
// I've already read article from this forum abt passing variables to the template engine
vB_Template::preRegister('SHOWTHREAD', array('vfsms_allowed4sticky_forums' => $vfsms_allowed4sticky_forums));
]]>
</phpcode>
</plugin>


And in template SHOWTHREAD I have next conditional:

{vb:raw $vfsms_allowed4sticky_forums}
{vb:raw $forumid}

<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin:10px">
<tr>
<td align="center">

<vb:if condition="$vbulletin->userinfo['userid'] == $threadinfo['postuserid'] AND ($threadinfo['sticky_till'] != '0000-00-00 00:00:00' AND $threadinfo['sticky'] == 1)">
Your thread is sticky untill <b style="color: red;">{vb:raw threadinfo.sticky_till}</b>!<br />
For prolongation send sms with the text <b style="color: red;">#vf sticky {vb:raw threadinfo.threadid}</b> to the number <b style="color: blue;">{$vbulletin->options[vfsms_sticky_num]}</b>.

<vb:elseif condition="$vbulletin->userinfo['userid'] == $threadinfo['postuserid'] AND $threadinfo['sticky_till'] == '0000-00-00 00:00:00' AND $threadinfo['sticky'] == 0 AND in_array($forumid, $vfsms_allowed4sticky_forums)" />

You can make your topic sticky by sending SMS with text <b style="color: red;">#vf sticky {vb:raw threadinfo.threadid}</b> to the number <b style="color: blue;">{$vbulletin->options[vfsms_sticky_num]}</b>.

<vb:else />
You can not make your topic sticky.
</vb:if>
</td>
</tr>
</table>


I have few problems:

1. variable $vfsms_allowed4sticky_forums can be accessed only as a {vb:raw vfsms_allowed4sticky_forums} and I can not put it to the condition
2. variable $forumid is not accessible anymore

Please, somebody, help me!

--------------- Added 1262737717 at 1262737717 ---------------

but everything is ok if I pass variable directly from the showthread.php:


1. find showthread.php:2228 print_output($templater->render());
2. replace on
$vfsms_can_stick_by_sms_forums_ids = str_replace(' ', '', $vbulletin->options['vfsms_can_stick_by_sms']);
$vfsms_allowed4sticky_forums = explode(',', $vfsms_can_stick_by_sms_forums_ids);
$templater->register('vfsms_allowed4sticky_forums', $vfsms_allowed4sticky_forums);
print_output($templater->render());


and in template also replace $forumid on $thread[forumid]

This is absolutely wrong way of doing the thing I need, pls tell me how to do it without changes in showthread.php!

well first off this is a thread for conditionals. Thats why your not getting much help with your whole script.

Do you have a conditional specific question? If not please start a new thread and do not hijack this one.

How would I make it so a profile option could disable a toolbar? To be more specific I am trying to make Tweetboard and Wibiya Toolbars optional via user options.

How would I make it so a profile option could disable a toolbar? To be more specific I am trying to make Tweetboard and Wibiya Toolbars optional via user options.

Do you have a conditional specific question? If not please start a new thread and do not hijack this one.

subscribed :)

Do you have a conditional specific question? If not please start a new thread and do not hijack this one.

I apologize. I was wondering for the conditional tags to use to accomplish this.

I apologize. I was wondering for the conditional tags to use to accomplish this.

You will need more then a conditional to accomplish this.

Right. From my understanding you make a custom profile field and then incorporate they field number into the conditional. No?

you may have to also register variables depending where you want to put it.



<vb:if condition="$bbuserinfo['fieldx']">

</vb:if>

I want to setup an alias for my forum, for the porn forum. So, how I can show that forum, ONLY if the people is accessing using the alias domain name?

In PHP It is easy, but i don't know how can be possible now in vB.

I could actually kiss you , great list was waiting for some one to get a list done like this.

I could actually kiss you , great list was waiting for some one to get a list done like this.

I at least hope your a female. ;)

Brilliant list mate :up:

Really helps, keep up the great work. Ste

Useful for adding a advertisement or other information after the first post on every page.

<vb:if condition="!$GLOBALS['FIRSTPOSTID']"></vb:if>

I want to use condition with the custom field. For example, I use custom field number 6 for private information, and I want the member can view it but hide it for everyone.

Is there any example?

Excellent thank you very much :)

I want to use condition with the custom field. For example, I use custom field number 6 for private information, and I want the member can view it but hide it for everyone.

Is there any example?

you can use this line to show only register user
<vb:if condition="$show['member']">Show this to members only</vb:if>

you can use this line to show only register user

sorry for my bad english. I mean the private information is showed for him only, the other members can not see it.

the condition you give is for every member... it can not be used in this case.

sorry for my bad english. I mean the private information is showed for him only, the other members can not see it.

the condition you give is for every member... it can not be used in this case.

this the one you're looking for huuquynh, replace the user id

<vb:if condition="$bbuserinfo['userid'] == 318713">Show this only to the member with the user id of 318713</vb:if>

Hi RL714,

I think your code is right. But this is not simple likes that, because it is not for only a member or owner site. I mean the number 318713 is the dynamic number, it is exactly userid in custom field table. So if condition is: $bbuserinfo['userid'] is exactly his userid, so he can see the value. But if the other member can not see.

For example: you can see your custom field number 6, but I can not see it. And vice versa, I can see my custom field number 6, but you can not see mine.

Thanks :)

Thank you for the article.

Please guide me in converting this to vb4:
<if condition="is_array($NewestMap)">and this one too please:
{$map_page}
{$NewestMap['m_image']}

Thanks for your article

I want to add advertisement after the first post in some special forums
so I edit the "ad_showthread_firstpost" Template and add this

<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

But nothing change in the special forums and the ads not appear

also if I used this
<vb:if condition="!in_array($forum[forumid], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

it's appear in all forums not only the special (1,2,3)

Can you advice me plz ?

Best regards

Hoping someone can help...

I'm trying to convert this template conditional (in threadbit, I'm guessing it matters)...

<if condition="! $ignore[ $thread['postuserid'] ]">

Using the guide here, I know it should look like this, but it doesn't work:

<vb:if condition="!$ignore[$thread['postuserid']]">

Could it be that the $ignore variable isn't available in that template? I've seen mention of that in other articles here, I think.

Anyone know a way of getting this to work?

<vb:if condition='"{vb:raw title}" == "The Latest"'><p>ME</p></vb:if>

{vb:raw title} returns The Latest exactly as I would expect when put into the style but for some reason it may not be working inside a conditional statement. =\

Anyone know a way of getting this to work?

<vb:if condition='"{vb:raw title}" == "The Latest"'><p>ME</p></vb:if>

{vb:raw title} returns The Latest exactly as I would expect when put into the style but for some reason it may not be working inside a conditional statement. =\

First off remember you can not use {vb:raw var} in template conditionals.

that

this is not work too with me :(
<vb:if condition="$forum[forumid] == x">Show this if forum id is x</vb:if>

anyone can advice ??

that

Yes well aren't I the ignorant one? Hahah

Do you know if there is any work around?

I have an idea.

I want to give someone control of their own thread. I figure that a good way to do that would be to duplicate the supermoderator group, calling it "threadModerator", then only display the "show admintools" dropdown IF the current user is both a threadAdmin AND is author of the current thread.

In other words, if the threadmoderator group is "100," How can I then say

If currently_logged_in_user is threadmoderator and
If currently_logged_in_user = thread_starter then
show admintools

I figure its something close to:

<vb:if condition="is_member_of($bbuserinfo, 100)">
<vb:if condition="is_author_of($thread)">
show admintools
</vb:if>
</vb:if>

It has to be something close to this...though I dont know how to query the system to find out the author of a thread...nor do I know how to reference the "show admintools" function...but I figure I've reasoned this out and given enough effort that one of you...who are MUCH better programmers than I...is willing to help me (and anyone that wants to use the code, giving myself and the person who cleans this up the credit).

How bout it people? Can someone help with this...?

What would the code be to only show on forumhome?

this is not work too with me :(
<vb:if condition="$forum[forumid] == x">Show this if forum id is x</vb:if>

anyone can advice ??

not work for me

Can any one tell me what i would have to use to get a sign to come up only when a thread is closed ?

So basically if a thread is closed i want a certain peace of HTML to show up

i need some help with the variables below to work with certian group and also an option not to show to certian groups can anyone help

so far i have this




<vb:if condition="is_member_of($bbuserinfo, {vb:raw vboptions.wmf_grp_perm})">
<vb:if condition="$vboptions['paypal_enable']">



<vb:else />
{vb:raw vboptions.wmf_closedreason}
</vb:if>


i need to where to add the section to not allow certain groups
i hope i got the code in the correct order so far

i wanna add {vb:raw vboptions.wmf_grp_noperm}

but not sure where to put it and if i need to add anything else to my exist code after the one i want inserted

lol Wish I would have saw this before. Oh well, I figured it out :P Thanks for this though!

Thanks for your article

I want to add advertisement after the first post in some special forums
so I edit the "ad_showthread_firstpost" Template and add this

<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

But nothing change in the special forums and the ads not appear

also if I used this
<vb:if condition="!in_array($forum[forumid], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

it's appear in all forums not only the special (1,2,3)

Can you advice me plz ?

Best regards

Same with me. Anyone know the correct conditionals?

Try this;

<vb:if condition="in_array($foruminfo[forumid], array(x,y,z))">
code here!
</vb:if>

:erm: errrmmm... hi

how about showing something here to a thread starter but not to his first post....is there any conditional on this please?

appreciate any help

thanks and best regards...

:p

Is there anything that I can pull the date of the last post of a thread?
$thread['lastpostdate'] or something like that. I'm trying to see if the last post date is older than 90 days and if so - output a custom phrase.
Thanks.

I'm trying to use a conditional to color code certain forums in the What's New and Search Results.

In search_threadbit I've tried the following, with no success (only the else shows for threads in these forums too.)
<vb:if condition="in_array($foruminfo[forumid],array(26,29,56,25,27))">
<div class="threadpostedin td alt">
<p>Test Different Color Div will go here For these Forums</p>
</div>
<vb:else />
<div class="threadpostedin td alt">
<p>
{vb:rawphrase forum}: <a href="{vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}" title="{vb:raw thread.forumtitleclean}">{vb:raw thread.forumtitle}</a>
</p>
</div>
</vb:if>
I thought that since forumid is actually in the link, it would be a piece of cake, but it's a no go as above. I must be missing something obvious.

I read here about assigning a variable to a template, so tried creating a new plugin to do so, but can't seem to make that work either. One question is that the template is labeled search_threadbit but that's not a choice in the add plugin screen for a hook location - only search_results_threabit which doesn't seem to exist as a template. So I'm a bit lost there.

Any guidance? Many thanks.
(new to VB4 today)

So how to properly construct a condition with {vb:raw var}?

Bumping this question. I have my conditional working but it would be more efficient if I could use it with a plugin for an external php page which updates several areas of my site at once so <vb:if condition="!is_member_of($bbuserinfo, 12)">{vb:raw includemyexternalpage}</vb:if> hides the section from usergroup 12.

Is it possible to put the condition in the plugin?

I'm trying to use a conditional to color code certain forums in the What's New and Search Results.

In search_threadbit I've tried the following, with no success (only the else shows for threads in these forums too.)
<vb:if condition="in_array($foruminfo[forumid],array(26,29,56,25,27))">
<div class="threadpostedin td alt">
<p>Test Different Color Div will go here For these Forums</p>
</div>
<vb:else />
<div class="threadpostedin td alt">
<p>
{vb:rawphrase forum}: <a href="{vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}" title="{vb:raw thread.forumtitleclean}">{vb:raw thread.forumtitle}</a>
</p>
</div>
</vb:if>
I thought that since forumid is actually in the link, it would be a piece of cake, but it's a no go as above. I must be missing something obvious.

I read here about assigning a variable to a template, so tried creating a new plugin to do so, but can't seem to make that work either. One question is that the template is labeled search_threadbit but that's not a choice in the add plugin screen for a hook location - only search_results_threabit which doesn't seem to exist as a template. So I'm a bit lost there.

Any guidance? Many thanks.
(new to VB4 today)
Sorry - I got lost and couldn't see the forest for the trees. Thanks to Lynne for pointing out that for the search_threadbit template $thread[forumid] not $foruminfo[forumid] was the ticket.

Is there an "at least this" conditional?

I have this conditional to list just the blogs from a specific category:

<vb:if condition="$blog['categories'] == 6">

It works well, but only if the blog entry is marked with only this category (6). If I choose one more category to the blog, let's say 5 and 6, this conditional no longer works.

Any help? =)

Hi, how would you direct guests to login with <if condition>?

I have a custom template being called at the template hook in the postbit called postbit_userinfo_right_after_posts which works fine with static text from the template outside of conditionals, however when I try to use text in a conditional or pull a field such as {vb:var post.fieldX}, nothing happens...

I am able to call conditionals in the postbit template without any problems, just not in the custom template.

The conditional and field I'm trying to use is:-

<vb:if condition="$post['fieldX']"><dt>Field Title</dt> <dd>{vb:var post.fieldX}</dd></vb:if>

Any ideas?

What about a conditional to have an ad appear after every 2 posts? used to be easy in vb 3.8, not now! :( :(

Hello,

I would like to show different size ads for memvers and guests, someone can help me to see if this code it's correct?

<vb:if condition="in_array($bbuserinfo['usergroupid'], array(usergroupshere))">
advert here
</vb:if>

Thanks

is there any conditional list to show something only if the said member is offline?
it means the below code belong to the user...so i want to hide it when they are online...
it can only be seen once that they are offline...is that possible guys?

<vb:if condition="$post['lastactivity']">
<dt>{vb:rawphrase last_online_activity}</dt><dd>{vb:raw post.lastactivity_date} {vb:raw post.lastactivity_time}</dd>
</vb:if>

appreciate any possible help on this guys...

thanks and best regards...

:o

is there any conditional list to show something only if the said member is offline?
it means the below code belong to the user...so i want to hide it when they are online...
it can only be seen once that they are offline...is that possible guys?

<vb:if condition="$post['lastactivity']">
<dt>{vb:rawphrase last_online_activity}</dt><dd>{vb:raw post.lastactivity_date} {vb:raw post.lastactivity_time}</dd>
</vb:if>

appreciate any possible help on this guys...

thanks and best regards...

:oany cofirmation at least for the thread starter or some more experienced coder out there please...or any respectable staff?

hmmm...:rolleyes:

Bump!-Bump!-Bump!

:mad:

It seems simple enough.. I wish I could help. Unfortunately I'm not familar in that area. Hopefully my response will help in attracting attention to your question. ;)

TalkVirginia...thanks a lot but i guess and notice that most of well experienced coder are not quite there anymore or interested of replying to any message who needs help regarding code like this or product...we have still some around but not paying or giving attention to post message like this...but if you post it to paid forum...they are quite fast and your pm box is full in a minute or 2....:p well thats my own opinion only...well i am not like that or tryin not to be like that...as long as i can...i am willing always to share my knowledge...or anything that i know...without any single cents...thanks is quite enough...

anyway hope someone who is more experienced coder someday will go reply here and share his knowledge...i might share him too some cents...;)

best regards to all

:p

I think most want us to do as much research on our own, provide our analysis and findings before they offer any input. Granted, this is important to do but sometimes we need a knudge in the right direction... sometimes. :) Off the top of my head I would say you might be able to find something already existing in postbit and/or postbit_legacy where it shows the online status icon. I'll have to go back and re-read the thread I guess in case that's not what you are looking for.

--------------- Added 1269596340 at 1269596340 ---------------

So how to properly construct a condition with {vb:raw var}?

for example, if {vb:raw var} is smaller than 6, show XYZ

I don't know if anyone has answered this or if you have already figured it out but you would need to handle this logic in your php code then render the variable accordingly.

I'd like to add that you can use AND & OR for example

<vb:if condition="$show['member'] AND THIS_SCRIPT == 'calendar'">show text</vb:if>

What about show to users having one post? Please? Thank you in advance! :)

Crystal clear - Subscribed.... thank you

I'm trying this in the css files stored among the templates. Anyone care to tell me whats wrong ? :)


html {
<vb:if condition="$post['field26']">
background-image:url($post[field26]);
<vb:else />
background:{vb:stylevar doc_background};
</vb:if>
}

is there a way to get this to work in a CMS article? or maybe with bbcode?

Can we set conditional to ONLY show if user has filled in Profile Field ? Otherwise it is blank

I've been working with some of the code provided here to show Adsense ads to non members only.

I found that using <vb:if condition... gave an error when trying to save the code.
Missing if statment relative to the </vb:if>

The following worked
<if condition="in_array($bbuserinfo['usergroupid'], array(1,3,4,8))">
Adsense code here
</if>

Wow thanks for this greatly appreciated; I have dedicated this entire day to me to fix up all the little things on my site such as all of the template edits, permissions and most importantly all of the conditionals and so this thread and the time taken to create it is greatly appreciated.

Show in several forums:
<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

I all templates i edit the above did not work.

What did work was:
<if condition="!in_array($GLOBALS[forumid], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

Though your conditional may work in some other templates.

Can someone tell me if this is right to put in our footer to not have something show on the CMS and to not show it to guests:

<vb:if condition="THIS_SCRIPT != 'CMS'"><vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Code here!</vb:if></vb:if>

I just want someone to tell me if it is correct, if not what is correct.

The correct this_script for CMS is

<vb:if condition="THIS_SCRIPT == 'vbcms'"></vb:if>

****UPDATE***

Ok, finally figured it out, had to pass in usergroups in the $show variable from the plugin.

So in the plugin:

$show[gm_ugs] = explode(',', trim($vbulletin->options['gm_user_groups_allowed']));

and in the template, the condition is:

<vb:if condition="is_member_of($bbuserinfo, $show[gm_ugs])">

I'm sure that's obvious to most of you, but... just incase someone else has the same question, hopefully that helps.


--------------------------

How do you check multiple usergroups in a template?

Such as:

<vb:if condition="is_member_of($bbuserinfo, $usergroups)">

where $usergroups = "6,15,10"

Specifically:

<vb:if condition="is_member_of($bbuserinfo, array($vboptions['gm_user_groups_allowed']))">

Is what I am trying, but it only seems to work if $vboptions['gm_user_groups_allowed'] is not an array and is a single value.

How would I make it so a profile option could disable a toolbar? To be more specific I am trying to make Tweetboard and Wibiya Toolbars optional via user options.



I have profile field 8 with radio single selection as the type. It's set with options of yes and no. It seems to be working.



<vb:if condition="in_array($bbuserinfo['field8'], array(yes))">
Script or code here
</vb:if>

I have profile field 8 with radio single selection as the type. It's set with options of yes and no. It seems to be working.



<vb:if condition="in_array($bbuserinfo['field8'], array(yes))">
Script or code here
</vb:if>


This would use many many less clock cycles and allocate less memory.


<vb:if condition="$bbuserinfo[field8] == 'yes'">
Script or code here
</vb:if>


And watch how you spell 'yes' when you create your custom fields, case matters.

Show is every forum but one: Remember to change x
<vb:if condition="$forum[forumid] != x">Show this if forum id is not x</vb:if>


Show in several forums:
<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>


Hello all,

How would I be able to make a mix of this? ie: Show in all forums except for 40, 41, and 42?

Cheers

Hello all,

How would I be able to make a mix of this? ie: Show in all forums except for 40, 41, and 42?

Cheers
I want to know how to do that too
coz the old conditional not work also the new one

I am curious if there is a conditional that I can use in the threadbit or forumhome template that will let me display X if a certain forum is being displayed...
$forum[forumid] doesn't work in the threadbit template, it has no value at all... is there an alternative way? Basically I want to only display something if forumdisplay.php?f=2 is the page I'm on.

subscribe.
K

Show Moderator of one forum: Remember to change x

<vb:if condition="can_moderate($forum['x'])">Show this if moderator is moderator of the forum with the id of x</vb:if>

This condition does not work. Shows in all forums and not just 'x' !!!

Hi guys..I have a donators group,
how can I show something only in the postbit of donators group list ?

Thanks :)

Hi guys..I have a donators group,
how can I show something only in the postbit of donators group list ?

Thanks :)

Edit the postbit (or postbit_legacy) and add

<vb:if condition="is_member_of($bbuserinfo, 9)">
Text or HTML to show to paid usergroup
</vb:if>


Change "9" to your paid usergroup id... if more than one then separate by comma: 9, 10, 11

Edit the postbit (or postbit_legacy) and add

<vb:if condition="is_member_of($bbuserinfo, 9)">
Text or HTML to show to paid usergroup
</vb:if>


Change "9" to your paid usergroup id... if more than one then separate by comma: 9, 10, 11

does, this show the defined text only to members or group 9 ??
..i want to show the text in the postbit of the every member of group 9, visible to other groups..

Thanks

That would show whatever you put above the </vb:if> only to users in usergroup id 9... If you want to display it to everyone you wouldn't use the IF statement at all. I don't think I fully understand the question.

if the member belongs to a group,,a text should appear in the post bit of that member..
which will be visible to every one..

Thanks :)

I have a piece of code added to the end of footer template but I want this piece of code to be visible only when i'm reading a thread (any thread).

May I ask if there's any conditional for this?

I have a piece of code added to the end of footer template but I want this piece of code to be visible only when i'm reading a thread (any thread).

May I ask if there's any conditional for this?

try this:

<vb:if condition="THIS_SCRIPT == 'showthread'">
Show this only in a thread
</vb:if>

Thanks, works great!

I would really benefit from a similar list of conditionals from php code, rather than conditionals. I can do nearly anything I want in a template thanks to this list, but trying to determine if a user is a member of a usergroup via php code is still foreign to me. Does anybody know of a list of these, or is anybody willing to translate this list to a php counterpart list? :)

Hello all,

How would I be able to make a mix of this? ie: Show in all forums except for 40, 41, and 42?

Cheers

Any idea on this?
Cheers

Can anyone assist me how to show a few texts on a certain time?
Let me explain,
I want my users see some texts displaying on site in the morning, however in the evening they will see another text on site.

Is there a conditional for that?

Any idea on this?
Cheers
<vb:if condition="!in_array($forum['forumid'], array(40, 41, 42))">Show if not in forumids 40, 41, or 42
</vb:if>

Can anyone assist me how to show a few texts on a certain time?
Let me explain,
I want my users see some texts displaying on site in the morning, however in the evening they will see another text on site.

Is there a conditional for that?
I think you are going to require more than a condition. You'll have to write plugin that takes TIMENOW (the current time in unix time) and converts it to the users time (don't forget that there are timezones to consider here) and then use the result there in your condition. You can look in the API here - http://members.vbulletin.com/api/ - for vbdate and that should help.

Can anyone assist me how to show a few texts on a certain time?
Let me explain,
I want my users see some texts displaying on site in the morning, however in the evening they will see another text on site.

Is there a conditional for that?

I think you are going to require more than a condition. You'll have to write plugin that takes TIMENOW (the current time in unix time) and converts it to the users time (don't forget that there are timezones to consider here) and then use the result there in your condition. You can look in the API here - http://members.vbulletin.com/api/ - for vbdate and that should help.
Thank you, Lynne
But I can't do that by myself. I hope someone handle it :erm:
I would like to use it for adsense.

Beautiful :)

Please Help.
I am unable to duplicate results in other Templates

I have been able to set linked images to show in the postbit_legacy template for custom profile fields with no problem using

<vb:if condition="$post['fieldx']">
my link and image information
</vb:if>

I tried
<vb:if condition="$bbuserinfo['fieldx']">
my link and image information
</vb:if>

But this shows the user who is viewing the informations link (if set) as apposed to the member who's profile they are viewing

So what I am asking is, is there an alternative conditional for?
<vb:if condition="$post['fieldx']">

or is there something I am missing else where?

Thank you in advance for any help....

does AND still work if I want to combine statements, for example if I want to combine if a person is a guest and the forum is 1, show this else show something else...how would I do that?

Just use 'AND'


<vb:if condition="$forum[forumid] == 5 AND $show['member']">Show this if forum id is 5 and user is a member.</vb:if>

yeah, thats what I tried, but I cannot seem to get the forumid thing to work, I am using one of the ad templates

You could try putting the condition in the header / footer or navbar template instead of the ad location... it will have the same ultimate effect.

So in the template FORUMDISPLAY I've done this:
<vb:if condition="!in_array($forum['forumid'], array(4, 5))"><vb:if condition="$show['newthreadlink']"><a href="newthread.php?{vb:raw session.sessionurl}do=newthread&amp;f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_top"><span>+</span> {vb:rawphrase post_new_thread}</a></vb:if></vb:if>
Except it isn't working, is there something I'm missing by some chance?

Cheers.

thanks

So in the template FORUMDISPLAY I've done this:
<vb:if condition="!in_array($forum['forumid'], array(4, 5))"><vb:if condition="$show['newthreadlink']"><a href="newthread.php?{vb:raw session.sessionurl}do=newthread&amp;f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_top"><span>+</span> {vb:rawphrase post_new_thread}</a></vb:if></vb:if>
Except it isn't working, is there something I'm missing by some chance?

Cheers.

I don't know if "$show['newthreadlink']" works in forumdisplay but if it does you're better off using an AND statement than two IF's...

<vb:if condition="!in_array($forum['forumid'], array(4, 5)) AND $show['newthreadlink']"><a href="newthread.php?{vb:raw session.sessionurl}do=newthread&amp;f={vb:raw foruminfo.forumid}" rel="nofollow" class="newcontent_textcontrol" id="newthreadlink_top"><span>+</span> {vb:rawphrase post_new_thread}</a></vb:if>

Hello,
The "$show['newthreadlink']" was in forumdisplay to begin with, I just added the array bit.

I tried what you gave, yet it still didn't hide the New thread button from display :/

What exactly are you trying to do- I know hide "New Thread" but under what conditions?

Essentially, we've got Easy Forms installed and we want users to only be able to submit a form on particular forums so they can follow a pre-defined template instead of being able to post whatever they want.
I've got a "Notice" on the forums saying with a bit of text, including a link to the needed form, but I know of no other way to hide the "New Thread" button.

I originally tried simply taking away permissions for Registered Users to Create New Threads, but then that wouldn't let them upload attachments to the form - which is a necessity.

If you know of any other way to do this, that would be greatly appreciated.

Hmmm... you could force users to use a specific style for that forum, and in that style you could remove the code for the new thread button completely... but that seems overkill... the IF condition should work... I'm surprised it's not.

I was surprised it didn't work either, unless there's something I might have missed?

Essentially, we've got Easy Forms installed and we want users to only be able to submit a form on particular forums so they can follow a pre-defined template instead of being able to post whatever they want.
I've got a "Notice" on the forums saying with a bit of text, including a link to the needed form, but I know of no other way to hide the "New Thread" button.

I originally tried simply taking away permissions for Registered Users to Create New Threads, but then that wouldn't let them upload attachments to the form - which is a necessity.

If you know of any other way to do this, that would be greatly appreciated.

You can make a plugin so that if the "New Thread" button is used it generates your form.

Hook Location: newthread_start
Two examples in the code below - (change the forum ID numbers and the form addresses)
if (in_array($forumid, array(1,2))) {
header( 'Location: http://www.xxxxxxx.org/forums/misc.php?do=form&fid=3' ) ;
}
if ($forumid==4)
{
header( 'Location: http://www.xxxxxxx.org/forums/misc.php?do=form&fid=5' ) ;
}

I want a user to be able to disable and enable a plugin that starts:

if ($vbulletin->options['mob_detect_enabled'] == 1)

So, I've created a profile field (for a setting) and I want to use this conditional inside the plugin so that ordinary members can disable it (it uses the style_fetch hook).

I think I need to add something like this at the top of the plugin, but in php ...

<vb:if condition="$bbuserinfo['fieldXXX'] === 'off'">
Stuff
<vb:else />
Different Stuff
</vb:if>Can anyone tell me how I write the same thing in PHP to get it to work?

Try


if ($vbulletin->options['mob_detect_enabled'] == 1 AND $bbuserinfo['fieldX'] == "off")
{
php stff
}
else
{
other php stuff
}

No that didn't do it ... but that may be down to my lack of php understanding.

Yeah the problem is the $bbuserinfo - there are various ways to access the same data, different ways work in different places... it may be something like $vboptions->bbuserinfo['fieldX'] or even $this->registry->bbuserinfo['fieldX'] but honestly I'm not sure of the exact syntax off hand, if you search around for it you should be able to find one that works, that's what I usually do.

try

$userinfo['fieldxx']

worked for me

it may be something like $vboptions->bbuserinfo['fieldX'] I tried that one to no avail.
or even $this->registry->bbuserinfo['fieldX']I'll have a go with the above a bit later (when nobody is on my site), thanks :)

try

$userinfo['fieldxx']
worked for meAlready tried that, and unfortunately it didn't do it.

You can make a plugin so that if the "New Thread" button is used it generates your form.

This worked!

Thanks to the people who helped, greatly appreciated. :)

I'll have a go with the above a bit later (when nobody is on my site), thanks :)
That didn't work either. I don't think the problem is the actual conditional though ... I just think that the plugin isn't accessing the profile information in order to apply it.

I all templates i edit the above did not work.

What did work was:
<if condition="!in_array($GLOBALS[forumid], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

Though your conditional may work in some other templates.
thanks for the correct code!

thanks for the correct code!

There is no possible way the code you quoted works... It starts of as VB3 condition with just: <if condition="..."> and ends with the VB4 conditional </vb:if>... so that code won't work in any version... In VB3 you don't use the "vb:" at all, in VB4 you need to use it every time.

I am trying to insert a an unique image heard for each of main page, HOME, Forum, What's New etc. How would you do that with condition?

Fore example: If you are on the Home page include home heard image, If you are on the Forum page include Forum image, and so on.

Please see attachments.

I am trying to insert a an unique image heard for each of main page, HOME, Forum, What's New etc. How would you do that with condition?

Fore example: If you are on the Home page include home heard image, If you are on the Forum page include Forum image, and so on.

Please see attachments.

You'd use this condition:

<vb:if condition="THIS_SCRIPT == 'calendar'">Show this only on calendar.php</vb:if>


You need to find out what the script names are for each page you want to show... I think home is "index" and forums is "forumdisplay"

So basically...


<vb:if condition="THIS_SCRIPT == 'index'">Image 1</vb:if>
<vb:if condition="THIS_SCRIPT == 'forumdisplay'">Index 2</vb:if>


Any other pages (like "showthread" and "calendar") won't show an image at all...

--------------- Added 1285699615 at 1285699615 ---------------

NEW POST HERE-- Stupid Auto Merge:rolleyes:


FYI This is a useful conditional if you want to hide the Facebook Like button in forums that aren't open to the public. If someone "Likes" a thread in a private forum people will be greeted with a no-permission "have to register" message which usually people will just get annoyed at rather than register. In fact if it's a private forum they may not even have access even after registering.

To use this conditional edit the SHOWTHREAD template... find the code:
<vb:if condition="$show['fb_likebutton']">

and change it too:

<vb:if condition="$show['fb_likebutton'] AND !in_array($threadinfo['forumid'], array(3,4,5))">


Where 3,4,5 are forum id's of the forums you want to hide the button in.

any "if condition" to show text/html only once on a certain place?

I am using CMS on my live site, and it has 1x2 content column on front page. I tried to place text/html/adsense code after first column however it always displays the text on all columns.

Any recommendations for that?

<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</vb:if>

what if I move someone to a group and then i wanted to show an image in the postbit for everyone to see IF that member is in a certain group.

In postbit you can use this to see if a member is in usergroup x.


<vb:if condition="$post['usergroupid'] == x">
-stuff-
</vb:if>

Great work i love it

I have tried this code below in my footer ad location and it display in all my usergroups. Is there something wrong with the code?

<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</vb:if>

I have tried this code below in my footer ad location and it display in all my usergroups. Is there something wrong with the code?

<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</vb:if>
What did the code you used look like?

I have tried this code below in my footer ad location and it display in all my usergroups. Is there something wrong with the code?

<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</vb:if>

This exact code is working fine in my footer, only issue would be is if you somehow pasted it in-between some other <if> code... Also are you sure you are using vBulletin 4.x? This won't work on 3.x.

Damn, my bad. this web site that I am trying to get it to work on is VB3. Sorry guys. Thanks for the help anyways. It will have to wait until i upgrade to VB4.

Thnaks

Damn, my bad. this web site that I am trying to get it to work on is VB3. Sorry guys. Thanks for the help anyways. It will have to wait until i upgrade to VB4.

Thnaks

The code for VB3 is very similar...

<if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</if>

BirdOPrey5

Thank you very much. that will hold me over until I update to VB4.

How can I insert a banner after X posts in vb4 ?

Thanks .

Assuming you mean in the postbit you'd use:
<vb:if condition="($post['postcount'] % 3) == 0">
banner code
</vb:if>



That would do it every 3rd post... change 3 to any number you want.

% is the modulus operator, it basically is the remainder in division- what you are saying in English is "when the post count is evenly divisible by 3, show the code."

Well I'm really scratching my head I'm trying to get a conditional to work only if in a certain forum if but also by postcount.

<vb:if condition="!in_array($postinfo['forumid'], array(2,4))">
<vb:if condition="!in_array($post['postcount'], array(7,35,63,91,119,147,175,203))">
Ad Here for forum id's 2 & 4
</vb:if>
</vb:if>

The text is showing but at the wrong post count and in the wrong forums....

Any clues - I'm working on the postbit template.

You're using the exclamation point "!" before "in_array" - the exclamation point means "NOT" so your first conditional reads "If NOT in forums 2 or 4, do something"

Just delete the !'s and you should be ok... also I'm not sure if $postinfo['forumid'] or just $post['forumid'] but one or the other should work.

Found out which conditional works...in postbit

<vb:if condition="in_array($GLOBALS[forumid], array(2,4))">

<vb:if condition="$bbuserinfo[field7] == 'No'">
<vb:else />
<!-- Wy MyFav Album Start -->
<vb:if condition="$post['field6']"><style="text-align:left"></dt> <img src="{vb:stylevar imgdir_misc}/myfavalbum/{vb:raw post.field6}.png" align="middle" alt="Members Fav Album" border="" /></vb:if>
<!-- Wy MyFav Album End -->
</vb:if>

I have a user profile field - No or Yes.

This doesn't seem to be working (it's in my postbit)

Any ideas? :)

In your postbit, you would use $post, not $bbuserinfo. $bbuserinfo is for showing you your own information anyway.

I'm attempting to create a tab with sublinks, with appropriate security.

I have the tab (Special access), with the drop down box (sublink 1, 2, 3) using this code:

I had to create a plugin with this code:

global $template_hook;
$newTemplate = vB_Template::create('dropdown');
$template_hook['navtab_end'] .= $newTemplate->render();

and a new template:


<li class="popupmenu">
<a href="javascript://" class="popupctrl navtab" style="background:transparent url({vb:stylevar imgdir_misc}/arrow.png) no-repeat {vb:stylevar right} center; padding-right: 15px">Special Access</a>
<ul class="popupbody popuphover">
<li><a style="text-indent: 0px; color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="http://domain.com.com/">Sublink 1</a></li>
<li><a style="color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="sublink2.php">SubLink 2</a></li>
<li><a style="color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="sublink3.php">SubLink 3</a></li>
</ul>
</li>


My question is how can I use a conditional where only those in the admin group can access it?

I'm attempting to create a tab with sublinks, with appropriate security.

I have the tab (Special access), with the drop down box (sublink 1, 2, 3) using this code:

I had to create a plugin with this code:

global $template_hook;
$newTemplate = vB_Template::create('dropdown');
$template_hook['navtab_end'] .= $newTemplate->render();

and a new template:


<li class="popupmenu">
<a href="javascript://" class="popupctrl navtab" style="background:transparent url({vb:stylevar imgdir_misc}/arrow.png) no-repeat {vb:stylevar right} center; padding-right: 15px">Special Access</a>
<ul class="popupbody popuphover">
<li><a style="text-indent: 0px; color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="http://domain.com.com/">Sublink 1</a></li>
<li><a style="color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="sublink2.php">SubLink 2</a></li>
<li><a style="color:{vb:stylevar navbar_selected_popup_body_a_Color}" href="sublink3.php">SubLink 3</a></li>
</ul>
</li>


My question is how can I use a conditional where only those in the admin group can access it?
Just use the conditional for usergroups as shown in the first post and wrap it around the code you want that group to have access to in your template.

Subbed

I don't know if anyone has answered this or if you have already figured it out but you would need to handle this logic in your php code then render the variable accordingly.
how would one do this?

i have in my plugin the following code:

$rkc_getobject = $vbulletin->input->clean_gpc('r', 'rkc_object', TYPE_UINT);

$rkc_variable1 = $vbulletin->db->query_first("
SELECT id, name, class_1, class_1_level
FROM " . TABLE_PREFIX . "rkc_table AS rkc_table
WHERE id = '" . $vbulletin->db->escape_string($rkc_getobject) . "'
");
$rkc_variable1['name'] = htmlspecialchars($rkc_variable1['name']);
$rkc_variable1['class_1'] = htmlspecialchars($rkc_variable1['class_1']);
$rkc_variable1['class_1_level'] = htmlspecialchars($rkc_variable1['class_1_level']);

And i want to display a conditional to accoplish something like the following:

<vb:if condition"($rkc_variable1['class_1']) == ClassType1">
selected code goes here
</vb:if>


now, i know i can use {vb:raw rkc_variable1.class_1} to post the contents in a template, but if i cannot use {vb:raw} in a conditional, how would this goal be accomplished?

When displaying the output of a variable you use:

{vb:raw rkc_variable1.class_1}


When testing in a condition you use:

$rkc_variable1['class_1']

I have tried many combinations using that, including what seems to be the most likely (for comparing a string to a string)

<vb:if condition"($rkc_variable1['class_1']='ClassType1')">Success <vb:else />Failure </vb:if>

Now, if i change it to ='' then it will return "Failure", but if anything at all is there, then it returns "Success".

My goal is to use a <select> menu for set options when editing an object currently saved to the database. Example:

Choose Class Type:
<select name="set_class1" id="set_class1" value="{vb:raw rkc_variable.class_1}">
<option value="">Choose Class</option>
<option value="ClassType1"<vb:if condition"($rkc_variable1['class_1']='ClassType1')"> selected="selected"</vb:if>>ClassType1</option>
<option value="ClassType2"<vb:if condition"($rkc_variable1['class_1']='ClassType2')"> selected="selected"</vb:if>>ClassType2</option>
</select>Every combination of conditional i have tried just returns the bottom value that has the conditional in it, in this example ClassType2 would show even if the set value in the database was ClassType1. My guess is its just a syntax issue on getting the conditional phrased just right.

if it helps, i have the following code in the plugin to register it:

$templater = vB_Template::Create('rkc_customtemplate');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('rkc_getobject', $rkc_getobject);
$templater->register('rkc_variable1', $rkc_variable1);
print_output($templater->render());

You definitely need equal signs in the conditionals...


<select name="set_class1" id="set_class1" value="{vb:raw rkc_variable.class_1}">
<option value="">Choose Class</option>
<option value="ClassType1"<vb:if condition="($rkc_variable1['class_1']='ClassType1')"> selected="selected"</vb:if>>ClassType1</option>
<option value="ClassType2"<vb:if condition="($rkc_variable1['class_1']='ClassType2')"> selected="selected"</vb:if>>ClassType2</option>
</select>


If that gives you an error try it without the single quotes around 'class_1' - sometimes they don't work right in templates.

i apologize for the inaccurate entry in my code. the code in my template did have the "=". However, the same problem exists. if i put the conditional only on the ClassType2 option, then no matter what ClassType is actually in the database, ClassType2 will always be the selected option.

Example: say the options range from 1-5. If i put the conditional on 2, and then choose 4, 4 will be stored in the database, but when bringing up that object to edit, option 2 will be the default choice in the select menu. Clicking to edit the object should show all default data currently stored, so that if you choose to edit and then 'save' without making any changes, no changes will be made. in this scenario, option 4 is in the database, but if you choose edit and then save w/o physically making any changes, option 2 will replace option 4.

<select type="text" name="set_class1" id="set_class1" value="{vb:raw rkc_variable1.class1}" class="primary">
<option value="">Choose Class1</option>
<option value="Option1">Option1</option>
<option value="Option2">Option2</option>
<option value="Option3">Option3</option>
<option value="Option4">Option4</option>
<option value="Option5">Option5</option>
<option value="Option6"<vb:if condition="($rkc_variable1['class1']='Option6')"> selected="selected"</vb:if>>Option6</option>
<option value="Option7">Option7</option>
<option value="Option8">Option8</option>
</select>
this code will always default the <select> to Class6, regardless of what the actual data in the table is. This is the problem i am having.

Hello there :) Thank you Digital Jedi!

I'm currently running a board under vB3.8 and will be upgrading shortly to the vB4.1.x series. Right now, we use a fluid banner.

We would like to approach our upgrade with a new design but still retain certain features that our members love, one of which - the fluid banner.

I've created a radio button in the user profile fields, so members can switch between which header style they'd like.

This is the code I've edited/changed in the header template.

<vb:if condition="$post[field8] == 'Yes'">
<div id="headerFill"><div id="headerL"></div><div id="headerR"></div></div>
<vb:else />
<div><a name="top" href="{vb:raw vboptions.forumhome}.php{vb:raw session.sessionurl_q}" class="logo-image"><img src="{vb:stylevar titleimage}" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" /></a></div>
</vb:if>


In theory, that should work? But I think the variable is wrong for the condition. Unless the field is specifically set to 'Yes' (default being 'No'..) then it should show the standard logo, correct?

Any help appreciated! :)

Greg

$post won't work in the header, $post is only defined inside a post... Also it the value of the poster not the value of the person viewing.

What you want is $bbuserinfo[field8], that holds the value of field8 for the user currently logged in.

As for the logic it would show
<div id="headerFill"><div id="headerL"></div><div id="headerR">
Only if the user specifically set this option to Yes. If it's set to "No" OR they never set the option it will show:
<div><a name="top" href="{vb:raw vboptions.forumhome}.php{vb:raw session.sessionurl_q}" class="logo-image"><img src="{vb:stylevar titleimage}" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" /></a></div>
instead.

This is good logic if you want users to have to "opt in" to this. If you wan't them to "opt-out" though (that is, display the first line unless they specifically said "No" then you'd be better off using the condition:
<vb:if condition="$bbuserinfo[field8] != 'No'">

There's also the underlying issue that the header HTML is completely different than VB3 and I doubt any code you have for VB3 could work for VB4. VB4 has a stylevar for the banner background.

I would like to thank Valter (http://www.vbulletin.org/forum/member.php?u=108756#hacks) for his contribution to solving my problem, even though he does not realize he helped! (I will PM him a thank you, as i found my working solution while browsing through a plugin written by him), and to you BirdOfPrey for your help as well.

My Solution:

First, i added another table with the data for the <select>. This will actually serve 2 purposes, 1st being solving my issue, and the 2nd allows me to create another admin page that will allow me to update the data in that table.


Inside the plugin code i added

...

$vbulletin->db->hide_errors();
$getlist= $vbulletin->db->query_read("
SELECT class_id, class_desc
FROM " . TABLE_PREFIX . "class AS class
ORDER BY class_desc ASC
");
$vbulletin->db->show_errors();
while ($class = $vbulletin->db->fetch_array($getlist))
{
$class_id = $class['class_id'];
$class_name = $class['class_desc'];
eval('$class_selector .= " <option value=\"'.$class['class_id'].'\" " . iif($rkc_variable1[class_1]==$class[class_id]," selected=\"selected\"","").">'.htmlspecialchars($class['class_desc']).'</option> ";');
}

...

$templater->register('class_selector', $class_selector);
$templater->register('class_name', $class_name);
$templater->register('class_id', $class_id);

Then in my template, i added the following code:

<td>
{vb:rawphrase class1_phrase}: <select id="set_class1" name="set_class1">{vb:raw class_selector}</select>
</td>

Thank you so much, BirdOPrey5 - That worked perfect :)

Nice post, very useful thank you very much
I just updated again to vb 4 and things got a little complicated, thanks for this great post

How would you clean this up into an array?

<vb:if condition="$vbulletin->nodeid != 1 AND THIS_SCRIPT != 'blog' AND THIS_SCRIPT != 'entry' AND THIS_SCRIPT != 'misc' AND THIS_SCRIPT != 'group' AND THIS_SCRIPT != 'calendar' AND THIS_SCRIPT != 'member' AND THIS_SCRIPT != 'usercp' AND THIS_SCRIPT != 'profile' AND THIS_SCRIPT != 'sendmessage' AND THIS_SCRIPT != 'register' ">

try...


<vb:if condition="$vbulletin->nodeid != 1 AND !in_array(THIS_SCRIPT, array('blog' , 'entry', 'misc', 'group'))">


and so on with your script names....

Thanks! :)

i have been trying to use $threadinfo[forumid] and $forum[forumid] in threadbit in a condition but it doesnt work .. is there any other vars i can use ?

In threadbit it looks like the variable is just:
$thread['forumid']

Hi,
I want to show an add in a specific forum, BUT I don't want it to show in the "SHOWTHREAD" under that specific forum. This is what I got:
<vb:if condition="$vbulletin->GPC['forumid'] == 37">

What shall I change/add to to make this happend? Thanks!

If you just want it to show in POSTS within a specific forum try:


<vb:if condition="$post['forumid'] == 37">

Thank!
But with that code it doesn't show at all.

I want it to show on this page:
http://support.elot.se/forum/hide-lite/

But not on this one:
http://support.elot.se/forum/hide-lite/1513-ljusreglering-av-led.html

What do you think?

My bad, you said DON'T show it in SHOWTHREAD, I mis-read the question.

Try one of these...

<vb:if condition="$forum['forumid'] == 37">
or
<vb:if condition="$foruminfo['forumid'] == 37">

I'm very greatful for your kind help. But these didn't work either. It doesn't show.

Any other suggestions? ;-)

Hmmm...

OK I just tested this in the template ad_navbar_below and it's working for me:


<vb:if condition="$GLOBALS['forumid'] == 37 AND THIS_SCRIPT=='forumdisplay'">

YES!!! There it was! Great! Thanks! :-)

Try this;

<vb:if condition="in_array($foruminfo[forumid], array(x,y,z))">
code here!
</vb:if>
Tnakyou this one works perfect
;) eyvallah

I tried this code, but for some reason it does not work

<vb:if condition="$forum[forumid] == 42">

<center><a href="WEB LINK"><img src="IMAGE LINK" alt="Our Secure Shopping Cart" />
</a></center>
</vb:if>

I tried this code, but for some reason it does not work

<vb:if condition="$forum[forumid] == 42">

<center><a href="WEB LINK"><img src="IMAGE LINK" alt="Our Secure Shopping Cart" />
</a></center>
</vb:if>

What template did you put it in?

Depending on the template there are different variables besides $forum[forumid], such as:


$foruminfo['forumid']
$GLOBALS['forumid']
$threadinfo['forumid']
$thread['forumid']

It was posted in forumdisplay

Thanks

Hello all. Firstly thanks for the list. It 'should' help me with what I'd like to do... but I need to ask for a bit of help here.

I'm trying to show the "Style Chooser" in the footer to ONLY certain user groups. I just can't figure where to place the code in the footer. Below is the portion of the footer code I think I should be working with:
<vb:if condition="$show['quickchooser']">
<select name="styleid" onchange="switch_id(this, 'style')">
<optgroup label="{vb:rawphrase quick_style_chooser}">
{vb:raw quickchooserbits}
</optgroup>
</select>
</vb:if>

I was using this bit of supplied code from the OP:
<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</vb:if>

Any ideas where to place the code?

Thanx

Since there's already a conditional, you should just add it to the existing conditional using an "AND" :


<vb:if condition="$show['quickchooser'] AND is_member_of($bbuserinfo, 1,2,3)">
<select name="styleid" onchange="switch_id(this, 'style')">
<optgroup label="{vb:rawphrase quick_style_chooser}">
{vb:raw quickchooserbits}
</optgroup>
</select>
</vb:if>


Where 1, 2, and 3 are the usergroups you want to show the chooser to.

You understand however any user could still change their style via their User CP options whether or not the quick-chooser is actually shown on every page.

...You understand however any user could still change their style via their User CP options whether or not the quick-chooser is actually shown on every page.

Hmmmmm Didn't think of that.

I did however figure another way around this. I set the option to change styles to yes, but only have the main theme I want the members to see selected in the "Style Manager." Seems I, as the admin, can see the other themes, but the regular members cannot.

That's true, the way to keep users from selecting styles is to uncheck them in the style manager. Only admins will have access to all styles (including unchecked styles.

What is Conditional tag for post count!

If (post count XXX)
do this 1
else
this 2?

What is Conditional tag for post count!

If (post count XXX)
do this 1
else
this 2?

If you are in the postbit and you want the post count of the person who made the post:


<vb:if condition="$post['posts'] >= XXX">
do this
<vb:else />
this
</vb:else>


If you want the post count of the current user logged in use:


<vb:if condition="$bbuserinfo['posts'] >= XXX">
do this
<vb:else />
this
</vb:else>

actually, that usually will not work if the post count is over 1000 since it is a formatted number, ie. 1,000

actually, that usually will not work if the post count is over 1000 since it is a formatted number, ie. 1,000

Is that new in VB4? I saw mention of this yesterday and tested it in my VB3.8 forum and my 22,000+ post count had no commas (22000) in VB 3.8. :confused:

On the plus side, usually when you're testing for post counts is some minimal number, 5, or 10, or even 100 which shouldn't be affected.

Is that new in VB4? I saw mention of this yesterday and tested it in my VB3.8 forum and my 22,000+ post count had no commas (22000) in VB 3.8. :confused:

On the plus side, usually when you're testing for post counts is some minimal number, 5, or 10, or even 100 which shouldn't be affected.
Maybe you are just not using commas to format large numbers on your forum? It has definitely been around since vB3 also.

Thank you both :)

The second is ok in my case!

The number of post is under 1000 so is ok also on vb4!

:)

Maybe you are just not using commas to format large numbers on your forum? It has definitely been around since vB3 also.

After double checking I see indeed $post[posts] is formatted with commas. I was using $bbuserinfo[posts] which isn't. (but of course contains different data.)

I am trying to find the new conditions for VB4.

Old condistion:
<if condition="$today_is_wednesday">Test</if>
I have tried this with no luck:
<vb:if condition="$today_is_wednesday">Test</vb:if>

Any ideas?

Try:

<vb:if condition="gmdate('D') == 'Wed' ">
Test
</vb:if>

Try:

<vb:if condition="gmdate('D') == 'Wed' ">
Test
</vb:if>



I tried putting the following conditions that you recommended in this code for a widget and even when it is not Wednesday it still displays. Any ideas or help would be appreciated.
<vb:if condition="gmdate('D') == 'Wed' ">
<b>Tonight is a chat night, Scheduled time is 8 pm.</b><br>
</vb:if>

This is the exact code I have working right now on my test forum:

<vb:if condition="gmdate('D') == 'Sat' ">
TESTING!!!!
</vb:if>


If I change Sat to any other day, it doesn't work. Yesterday it worked with Fri instead.

I have this working in my Navbar template.

I've never used widgets, do template conditionals work in them at all?

I did notice a limitation, gmdate returns Greenwich Mean Time, so it works when it's Wednesday in Greenwich, England.
http://us.php.net/manual/en/function.gmdate.php

Unfortunately vBulletin doesn't seem to allow the regular date() function which returns the local date, so this may not work well for you anyway.

FYI- Your code pasted into my navbar works fine.

is it possible to use a conditional to check whether you're viewing ONLY the very front page (CMS)?

e.g. I'd like to add a link in the footer of just the CMS's front page - but not on any other pages, not show if they're reading an article, not show if they're using forum or blogs, etc. etc. - just the front page and only the front page.

is it possible to use a conditional to check whether you're viewing ONLY the very front page (CMS)?

e.g. I'd like to add a link in the footer of just the CMS's front page - but not on any other pages, not show if they're reading an article, not show if they're using forum or blogs, etc. etc. - just the front page and only the front page.
Try this....
<vb:if condition="THIS_SCRIPT == 'vbcms'">Show this</vb:if>

Thanks HM, but that shows when reading articles too... I need the code to only show on the front page alone - not articles/comments... If you have any ideas on narrowing it down, that would be most appreciated :)

I'm not sure that's possible since the articles/comments run off of that same script....

One more thing...

how to do a OR condition.

<vb:if condition="$xxx" OR condition="$yyy" >
With OR and || is not working...

One more thing...

how to do a OR condition.

<vb:if condition="$xxx" OR condition="$yyy" >
With OR and || is not working...

it's...


<vb:if condition="($x == $y) OR ($x == $z)">

Thank you BirdOPrey5 (http://www.vbulletin.org/forum/member.php?u=258922)

:)

I want to restrict some custom BBcodes to only certain usergroups (moderators and higher).

I tried to wrap BBcode inside this statment, but it doesn't work:

<vb:if condition="$post['usergroupid'] == 6">

Any idea how BBcode use could be restricted only to certain usergroups?

Conditionals like these (Template Conditionals) only work in templates, they don't work in BB Codes.

There is a mod, "Advanced BB Code Manager" (http://www.vbulletin.org/forum/showthread.php?t=122942) that is for an older version of vBulletin but still works on the latest 4.x it has been reported.

Only way of doing this without writing your own mod.

Thank you. It would be good if someone makes new mod for managing BBcode. Hopefully someone would...

Is there a condition for all pages/content with a certain section of the cms?

Some more conditions you can add to your list:

Show only if vBulletin notices are not shown

<vb:if condition="!$show['notices']">
</vb:if>
For use in template navbar: Show only in Forum ID X

<vb:if condition="$GLOBALS[forumid] == X">
</vb:if>



But I have one question.
Is there a condition to show something only in the second post of each thread and page?
Something like "isfirstshown" just for the second post?

There's no condition specifically for 2nd posts but if you set your forum to a set number of posts per page you could make a condition like:

<vb:if condition="$post[postcount] == 2 OR $post[postcount] == 12 OR$post[postcount] == 22 OR $post[postcount] == 32 OR $post[postcount] == 42 OR $post[postcount] == 52 OR $post[postcount] == 62">
</vb:if>

...and so on... Assuming 10 posts per page- Yeah at some point the condition won't work anymore but how many threads really go X number of pages anyway. I assume you want it to show an ad so if it works in 95% of thread pages it should be good enough.

Otherwise I'd imagine a plugin could be written to keep count and be true only for 2nd posts.

how is conditional syntax for the thread that has been closed?

example:

<vb:if condition="closed thread???"> show message cause thread that has been closed </vb:if>

In the showthread template there is this code:

<vb:if condition="$show['closethread']"><span>+</span> {vb:rawphrase reply_to_thread}<vb:else />{vb:rawphrase closed_thread}</vb:if>

So <vb:if condition="$show['closethread']"> is the condition but if it's TRUE the thread is OPEN, if it's FALSE the thread is closed... at least that is what it looks like to me.

This conditional is being placed in a forum block, but doesn't work correctly. I only wish to display the code to members who are logged in. Not guests.

Here's what I have:


<vb:if condition="$show['member']">

sadly, everyone sees this even those who are not logged in.

</vb:if>What's the correct way of writing this?

Thanks!

@BirdOPrey5
thx, but its not work to me.. :(
* my code at postbit_legacy


@tundrasoul
may be this..?


<vb:if condition="$show['guest']">
<vb:else />
Show this to all not guest users

</vb:if>

<vb:if condition="$show['guest']">
<vb:else />
Show this to all not guest users

</vb:if>

No, that didn't work either. The code still display to everyone.

or this.. ?


<vb:if condition="!is_member_of($bbuserinfo, 1)">Show this to user group not guest</vb:if>


usergroup 1 = guest

or this.. ?


<vb:if condition="!is_member_of($bbuserinfo, 1)">Show this to user group not guest</vb:if>
usergroup 1 = guest

It makes no sense, it should be but it doesn't. vB 4.13.

The code still displays to everyone including guests.

@tundra
this is worked for me :

<vb:if condition="$bbuserinfo['usergroupid'] == 1">
showing just for guest..
<vb:else />
showing other guest
</vb:if>

@tundra
this is worked for me :

<vb:if condition="$bbuserinfo['usergroupid'] == 1">
showing just for guest..
<vb:else />
showing other guest
</vb:if>



Did you try it in the forum block code?

It doesn't work there for me, using vB 4.13.

@BirdOPrey5
thx, but its not work to me.. :(
* my code at postbit_legacy


@tundrasoul
may be this..?


<vb:if condition="$show['guest']">
<vb:else />
Show this to all not guest users

</vb:if>

Both you guys are probably having the same issue, the variable isn't used in your template by default so you must register it there. There's another article here on how to register variables for use in templates: http://www.vbulletin.org/forum/showthread.php?t=228078

For example the closedthread check is only done in showthread, not postbit, so you have to pre-register it for postbit.

hi

how to display Google ads to the guest and in home page only?

hi

how to display Google ads to the guest and in home page only?
Assuming your "home page" is the forum.php page....
<vb:if condition="$show['guest'] AND THIS_SCRIPT == 'index'">
ad
</vb:if>

Assuming your "home page" is the forum.php page....
<vb:if condition="$show['guest'] AND THIS_SCRIPT = 'index'">
ad
</vb:if>



thanks lynne

but this will occur


Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 3416

The following error occurred when attempting to evaluate this template:
%1$s
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish

Change the = to == and try again. :)

How can I create a condition based on "Social Groups" (no user groups)? I tried this but it didn't work:

<vb:if condition="($bbuserinfo['groupid'] <> 2) ">

CONTENTS GO HERE

</vb:if>

Where are you trying to use this conditional?

I want to use it in the footer template.

My site uses a floating tool bar. For members that want to hide the tool bar all together, I want to allow them to add themselves to the social group, "Hide Tool Bar". I then want to use the conditional to hide the tool bar code if the user is a member of this social group.

I want to use it in the footer template.

My site uses a floating tool bar. For members that want to hide the tool bar all together, I want to allow them to add themselves to the social group, "Hide Tool Bar". I then want to use the conditional to hide the tool bar code if the user is a member of this social group.

Ahh... OK, well that will never work with social groups.

Luckily however vBulletin has a built in feature, publicly joinable usergroups that should work exactly as you describe.

In your Usergroup manager in Admin CP, make a new usergroup based off of registered users. Set the option to make it a publicly joinable usergroup. Call it "Hidden Toolbar" or whatever.

Members can join it via the User CP -> Group Memberships

And then you can use the standard condition:

<vb:if condition="is_member_of($bbuserinfo, X)">

Where X is the usergroup you made.


OR... now that I've typed that out... The "right" way of doing this would be using a Custom Profile Field.

In Admin CP make a New Custom Profile Field... Basically a "Yes/No" option to turn on/off the toolbar...

Then you would use a condition like:

<vb:if condition="$bbuserinfo['fieldX'] == 'Yes' ">

Where X is the field # assigned by vBulletin.

I can give you more details on this if you think it will work for your needs.

I used the custom profile field solution. Thank you so much!!!!

Is there a conditional to use if one would like to show something only to the member who posted the post?

For example:
I created a custom field that I would like for the member to enter information into that s/he and the admin can see when posted, but no other members can see. (A secure field - if you will).

Thanks,
Kether

You could do a condition to show code only to the user who posted it...

<vb:if condition="$bbuserinfo['userid'] == $post['userid']">
(will work in the postbit)


But you'd still need to make the extra field to hold the data and everything else needed to process it. The conditional is the easy part.

You could do a condition to show code only to the user who posted it...

<vb:if condition="$bbuserinfo['userid'] == $post['userid']">
(will work in the postbit)


But you'd still need to make the extra field to hold the data and everything else needed to process it. The conditional is the easy part.

Thanks Joe. I was able to create the extra field, just couldn't figure out how to show it's contents only to the member who posted and admin instead of everyone who could see the post.

I will give you code a go. Thanks for your quick help. I appreciate it very much.

Kether

--------------- Added 1307976670 at 1307976670 ---------------

Thanks Joe. I was able to create the extra field, just couldn't figure out how to show it's contents only to the member who posted and admin instead of everyone who could see the post.

I will give you code a go. Thanks for your quick help. I appreciate it very much.

Kether


Well, I am still having trouble getting this to work. I guess I need a conditional to show a field only to the admin user group and the individual who posted the information.

So, I use the following code to identify a field, but need help with the conditional to make it only be seen by the admin group and the individual who posted the information:

<vb:if condition="$field['fieldid'] == 6">

Any suggestions? Thanks again.
Kether

The important thing about the conditional I gave you is it only works in posts/the postbit.

You could show it to admins OR the user who's viewing his own post with:



<vb:if condition="($bbuserinfo['userid'] == $post['userid']) OR (is_member_of($bbuserinfo, 6))">


Where 6 is the usual usergroup for admins.

But the fact your mentioning fields makes me think this code isn't for the postbit.

If you're using custom profile fields you can mark them as private to limit who sees them.

The important thing about the conditional I gave you is it only works in posts/the postbit.

You could show it to admins OR the user who's viewing his own post with:



<vb:if condition="($bbuserinfo['userid'] == $post['userid']) OR (is_member_of($bbuserinfo, 6))">


Where 6 is the usual usergroup for admins.

But the fact your mentioning fields makes me think this code isn't for the postbit.

If you're using custom profile fields you can mark them as private to limit who sees them.


No actually, I am editing the SHOWENTRY template in vbadvanced dynamics. I have added custom fields and would like to specify who can see one or two specific private fields. Sorry I did not make that clear in the first place.

The bit of code I put in my previous 'merged' post:

<vb:if condition="$field['fieldid'] == 6">

Tells the forum to put the information in field 6 in that location in the SHOWENTRY. I want to wrap a conditional around it to only display the information in field '6' to the admin group and the person who actually posted the information in the first place.

I believe it should be fairly simple to wrap a conditional around this conditional, but so far I have not been able to figure it out.

Thanks for your response.

Kether

No actually, I am editing the SHOWENTRY template in vbadvanced dynamics. I have added custom fields and would like to specify who can see one or two specific private fields. Sorry I did not make that clear in the first place.

The bit of code I put in my previous 'merged' post:

<vb:if condition="$field['fieldid'] == 6">

Tells the forum to put the information in field 6 in that location in the SHOWENTRY. I want to wrap a conditional around it to only display the information in field '6' to the admin group and the person who actually posted the information in the first place.

I believe it should be fairly simple to wrap a conditional around this conditional, but so far I have not been able to figure it out.

Thanks for your response.

Kether

Well this will limit it to administrators but I would have no way of knowing the conditional vbadvanced dynamics might use to know which user posted it- that would be a question better asked at their own forums- they'll know what's possible with their product.


<vb:if condition="$field['fieldid'] == 6 AND is_member_of($bbuserinfo, 6)">


The combined code, assuming you can find a conditional from vb advanced would be something like:


<vb:if condition="$field['fieldid'] == 6 AND (is_member_of($bbuserinfo, 6) OR OTHER_CONDITION_HERE)">

Why, this code is now working for me on postbit_legacy template:



<vb:if condition="$onlinestatus==1">Online</vb:if>
<vb:if condition="$onlinestatus==0">Offline</vb:if>
<vb:if condition="$onlinestatus==2">Privat</vb:if>
I get only OFFLINE :S even the user is online.

Well this will limit it to administrators but I would have no way of knowing the conditional vbadvanced dynamics might use to know which user posted it- that would be a question better asked at their own forums- they'll know what's possible with their product.


<vb:if condition="$field['fieldid'] == 6 AND is_member_of($bbuserinfo, 6)">


The combined code, assuming you can find a conditional from vb advanced would be something like:


<vb:if condition="$field['fieldid'] == 6 AND (is_member_of($bbuserinfo, 6) OR OTHER_CONDITION_HERE)">


Thanks again. I have posted for help at vbadvanced, but no one has replied over there. I just replied to myself there with your suggestion so maybe that will encourage someone to offer up the missing bit of code. Still looking.

Much appreciative,
Kether

Why, this code is now working for me on postbit_legacy template:



<vb:if condition="$onlinestatus==1">Online</vb:if>
<vb:if condition="$onlinestatus==0">Offline</vb:if>
<vb:if condition="$onlinestatus==2">Privat</vb:if>
I get only OFFLINE :S even the user is online.

Try using $post['onlinestatus'] instead of $onlinestatus. Not sure it's the same data but I can see $onlinestatus is never used in the postbit template so if $post['onlinestatus'] doesn't work you'll need to make a plugin to register $onlinestatus in the postbit.

$post['onlinestatus'] is not working to :(

Can you help me how to register a variable for template?

Or can I make something like, if POSTBIT A, else B??

Thank you!

Unfortunately preregistering variables was never something I mastered, one of the big reasons I prefer VB 3.x over VB 4.x. I just try to avoid doing anything where I have to preregister.

This is the article that is supposed to help: http://www.vbulletin.org/forum/showthread.php?t=228078

I'm not sure what yo mean by POSTBIT A and B?

Thank you!

what are the conditions so only friends can see...and yes logged in to see...

Unfortunately preregistering variables was never something I mastered, one of the big reasons I prefer VB 3.x over VB 4.x. I just try to avoid doing anything where I have to preregister.

This is the article that is supposed to help: http://www.vbulletin.org/forum/showthread.php?t=228078

I'm not sure what yo mean by POSTBIT A and B?

If I make a plugin for postbit_legacy, on what Hook Location I have to send?

Thank you!

The only template $onlinestatus is used is postbit_onlinestatus.

postbit_legacy is a template, you wouldn't make a plugin on a template, you'd make a plugin on a hook. Some hooks are postbit_display_start and posbit_display_complete. There are many others of course but I'd imagine you'd need to make a plugin on one of them.

Great! Thank you...

Hey Joe, if you are still reading this thread, I have an update and a question.

As I said, I posted at vbadvanced.com and finally got a response that helped a bit, but I haven't solved the complete issue. I am so close and was hoping if you see what I have you could offer a suggestion:

SO, I have finally got the custom field to display to both the admin and the user who posted it. Now, I need an else statement that tells the forum to not display it to any one else.

Here is what I have:

<vb:if condition="$field['fieldid'] == 5 AND (is_member_of($bbuserinfo, 6) OR $bbuserinfo['userid'] == $entry['userid'])">
<div>{vb:raw entry.field5}</div>
</vb:if>

I need an else statement to follow this that says if anyone else is viewing this, do not post the information in {vb:raw entry.field5}.

Any ideas?

Thanks,
Kether

Hey Joe, if you are still reading this thread, I have an update and a question.

As I said, I posted at vbadvanced.com and finally got a response that helped a bit, but I haven't solved the complete issue. I am so close and was hoping if you see what I have you could offer a suggestion:

SO, I have finally got the custom field to display to both the admin and the user who posted it. Now, I need an else statement that tells the forum to not display it to any one else.

Here is what I have:

<vb:if condition="$field['fieldid'] == 5 AND (is_member_of($bbuserinfo, 6) OR $bbuserinfo['userid'] == $entry['userid'])">
<div>{vb:raw entry.field5}</div>
</vb:if>

I need an else statement to follow this that says if anyone else is viewing this, do not post the information in {vb:raw entry.field5}.

Any ideas?

Thanks,
Kether

An else statement is if you want to display alternative information, an example would be:

<vb:if condition="$field['fieldid'] == 5 AND (is_member_of($bbuserinfo, 6) OR $bbuserinfo['userid'] == $entry['userid'])">
<div>{vb:raw entry.field5}</div>
<vb:else />
<div>You are not allowed to see this field.</div>
</vb:if>

You do not need an "else" to tell it not show anything, that is implied in the original IF to behgin with.

An else statement is if you want to display alternative information, an example would be:

<vb:if condition="$field['fieldid'] == 5 AND (is_member_of($bbuserinfo, 6) OR $bbuserinfo['userid'] == $entry['userid'])">
<div>{vb:raw entry.field5}</div>
<vb:else />
<div>You are not allowed to see this field.</div>
</vb:if>

You do not need an "else" to tell it not show anything, that is implied in the original IF to behgin with.

Oh, then I suppose I have another issue then. The custom field is still displayed to everyone. If logged in as the member who posted it or as the admin, it is displays correctly. For everyone else, the information is just there. :( I was hoping I could use an else statement with an "!=" in it somehow and make it not display.

I really appreciate your help. Wish I could get a response as fast in the vba site. :)

Thanks,
Kether

-----------

I wonder if instead of editing a template, I should be editing a php file and putting the condition around a specific field ID. So, if that field ID is called, it will only be displayed to the conditions of the field. Not sure here.... just guessing. Thoughts?

Editing the PHP wouldn't be of any help- any condition you can test in PHP you can test in the template.

The only part of your conditional I don't know off hand is $entry['userid']- I've never used it before so I don't know what data it's returning.

In the template put this code:


{vb:raw entry.userid}


That should have it "print out" the value of the variable so you can see exactly what is stored in it. My guess is it's not storing the value you expect. Make sure to test it with multiple users.

EDIT- Looking over your code are you sure it's $field['fieldid'] and not $entry['fieldid'] ?

Editing the PHP wouldn't be of any help- any condition you can test in PHP you can test in the template.

The only part of your conditional I don't know off hand is $entry['userid']- I've never used it before so I don't know what data it's returning.

In the template put this code:


{vb:raw entry.userid}


That should have it "print out" the value of the variable so you can see exactly what is stored in it. My guess is it's not storing the value you expect. Make sure to test it with multiple users.

EDIT- Looking over your code are you sure it's $field['fieldid'] and not $entry['fieldid'] ?

I copied what was given to me at vba.com. So, yes, $field['fieldid'] is correct. I will try it with $entry['fieldid'] to see if it makes any difference. (Wouldn't that be lovely if it fixed it!?!)

$entry['userid'] - I believe is returning the user who posted the article. (But again- I am guessing as I copied what suggested.) I will work on it some more and post back anything I find. Thanks Joe!!

Kether

--------------- Added 1308935315 at 1308935315 ---------------


In the template put this code:


{vb:raw entry.userid}


That should have it "print out" the value of the variable so you can see exactly what is stored in it. My guess is it's not storing the value you expect. Make sure to test it with multiple users

Tested it with multiple users from different user groups. The results returned are the same. A number: 122
Not sure what to make of that as it is not a field id nor is it a user id. But it always placed it where i put that code.

Kether

Sorry man... VBA Dynamics is a commercial mod I just don't have access to so I don't know how it's designed or what fields may be available.

If there is a php hook available somewhere you could make a plugin with this code, it will print out all available fields for $entry and see if any of them match the userid.


echo "<pre>";
print_r ($entry);
echo "</pre>";


But don't do it while your forum is on (use a test forum if you have one) otherwise everyone will see the code output.

Sorry man... VBA Dynamics is a commercial mod I just don't have access to so I don't know how it's designed or what fields may be available.

If there is a php hook available somewhere you could make a plugin with this code, it will print out all available fields for $entry and see if any of them match the userid.


echo "<pre>";
print_r ($entry);
echo "</pre>";


But don't do it while your forum is on (use a test forum if you have one) otherwise everyone will see the code output.

Thanks for your efforts! I am grateful!

Regards,
Kether

--------------- Added 1309015535 at 1309015535 ---------------

Just a follow-up update: I finally figured it out with your help, Joe. I went to the template and just started deleting bits and checking to see what was displayed. I found the bit that was causing the information to be displayed to everyone even though we told it to only display to the admin and user. After removing that code. It all worked!! Thanks again for your help. I appreciate it very much.

Kether

Hello,

Am looking for a template conditional for Blog pages.

I tried this:

<vb:if condition="THIS_SCRIPT == 'blog'">


but this works only for the blog home page.

I would want a template conditional that applies to all the blog pages.

Thanks.

There's no condition specifically for 2nd posts but if you set your forum to a set number of posts per page you could make a condition like:

<vb:if condition="$post[postcount] == 2 OR $post[postcount] == 12 OR$post[postcount] == 22 OR $post[postcount] == 32 OR $post[postcount] == 42 OR $post[postcount] == 52 OR $post[postcount] == 62">
</vb:if>...and so on... Assuming 10 posts per page- Yeah at some point the condition won't work anymore but how many threads really go X number of pages anyway. I assume you want it to show an ad so if it works in 95% of thread pages it should be good enough.

An approach I have tested out but collided with other ads around the last post on a thread, if the showthread page contains only two or three postings. To overwhelming and filled with ads.

I try to modify and create the ad-placements with a precheck, wether there are more then X posts on a showthread page or not. Dependencies:
if the visitor is a guest
if the ad placement is the X post on this showthread page as seen in the browser
if the page (not the whole thread) shows at least Y postings (to avoid that the whole page is looking like an adfarm)
<vb:if condition="$show['guest']">
<vb:if condition="$post['postcount'] % $vboptions['maxposts'] == X">
[CONTENT HERE]

</vb:if>
</vb:if>
Thatīs how it looks like so far - but I canīt find anything that could help me with the last if statement. Does anyone has an idea how this could be done? Isnīt there something in vB that can be used for that? May be Iīm just to blind but that damn thing ruined my whole day yesterday. I would be glad someone could lead a blind and help me out of this mess..

Any help appreciated.

Hello,

Am looking for a template conditional:

In Showthread page - postbit, the username of the poster needs to be in red color if she belongs to a particular usergroup id - 34, I tried this

<vb:if condition="is_member_of($post, 34)">
<span style="color:red;"> User name goes here</span>
</vb:if>


But it does not seem to be working and I did the above template conditional in memberaction_dropdown

Let me know the correct conditional that needs to go there.

BTW the conditional to check if the page is a blog page including the blog index use the below:

<vb:if condition="in_array(THIS_SCRIPT, array('blog' , 'entry','blog_post', 'misc'))">
Code goes here
</vb:if>

Thanks.

In Showthread page - postbit, the username of the poster needs to be in red color if she belongs to a particular usergroup id - 34

If I donīt get you wrong, thatīs already a built-in feature. Check the settings of the usergroup 34 in the usergroup-settings, 3rd checkbox should be the one you are looking for.

Hello Marv,

Thanks for the response. Guess you are talking about the "Username HTML markup".

But this user has the usergroup id - 34 as her secondary user group ( and not primary user group). Hence the HTML markup - color code set in the usergroup setting is not output in the postbit.

let me know how to obtain this.

Thanks in advance.

I think the condition is correct. Are you using post.musername or post.username? post.musername includes the group markup, which is probably overriding your color, so try post.username.

Hello,

Am looking for a template conditional:

In Showthread page - postbit, the username of the poster needs to be in red color if she belongs to a particular usergroup id - 34, I tried this

<vb:if condition="is_member_of($post, 34)">
<span style="color:red;"> User name goes here</span>
</vb:if>


But it does not seem to be working and I did the above template conditional in memberaction_dropdown

Let me know the correct conditional that needs to go there.

BTW the conditional to check if the page is a blog page including the blog index use the below:

<vb:if condition="in_array(THIS_SCRIPT, array('blog' , 'entry','blog_post', 'misc'))">
Code goes here
</vb:if>

Thanks.

I don't think $post can be used in memberaction_dropdown. I don't know what the alternative would be either- would probably need some custom plugins I think.

memberaction_dropdown is called from many different templates, not just the postbit.

Oh, good point Joe, I saw postbit and missed memberaction_dropdown. Sorry induslady.

ETA: Actually I think you might be able to substitute $memberinfo for $post. You still may have to use username instead of musername.

How can I insert a banner in the first post of the every pages of the thread ?










privacy (GDPR)