vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   vB4 Template Conditionals List (https://vborg.vbsupport.ru/showthread.php?t=231525)

BirdOPrey5 05-26-2011 03:44 PM

In the showthread template there is this code:

Code:

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

<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.

TundraSoul 05-26-2011 07:05 PM

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:

Code:

<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!

Hasanudin 05-26-2011 07:14 PM

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


@tundrasoul
may be this..?

Code:

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

</vb:if>


TundraSoul 05-26-2011 07:27 PM

Quote:

Originally Posted by Hasanudin (Post 2200318)

Code:

<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.

Hasanudin 05-26-2011 07:36 PM

or this.. ?

Code:

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

TundraSoul 05-26-2011 07:47 PM

Quote:

Originally Posted by Hasanudin (Post 2200326)
or this.. ?

Code:

<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.

Hasanudin 05-26-2011 09:04 PM

@tundra
this is worked for me :
Code:

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


TundraSoul 05-26-2011 09:22 PM

Quote:

Originally Posted by Hasanudin (Post 2200354)
@tundra
this is worked for me :
Code:

<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 05-27-2011 03:40 PM

Quote:

Originally Posted by Hasanudin (Post 2200318)
@BirdOPrey5
thx, but its not work to me.. :(
* my code at postbit_legacy


@tundrasoul
may be this..?

Code:

<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: https://vborg.vbsupport.ru/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.

baghdad4ever 06-08-2011 01:38 PM

hi

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

Lynne 06-08-2011 02:36 PM

Quote:

Originally Posted by baghdad4ever (Post 2205038)
hi

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

Assuming your "home page" is the forum.php page....
Code:

<vb:if condition="$show['guest'] AND THIS_SCRIPT == 'index'">
ad
</vb:if>


baghdad4ever 06-08-2011 06:10 PM

Quote:

Originally Posted by Lynne (Post 2205060)
Assuming your "home page" is the forum.php page....
Code:

<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

BirdOPrey5 06-08-2011 09:03 PM

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

ChromeDome 06-11-2011 02:02 PM

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

Code:

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

CONTENTS GO HERE

</vb:if>


BirdOPrey5 06-11-2011 02:30 PM

Where are you trying to use this conditional?

ChromeDome 06-11-2011 03:09 PM

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.

BirdOPrey5 06-11-2011 04:29 PM

Quote:

Originally Posted by ChromeDome (Post 2206251)
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:

Code:

<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:

Code:

<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.

ChromeDome 06-11-2011 05:37 PM

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

kether1 06-12-2011 05:58 PM

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

BirdOPrey5 06-12-2011 06:11 PM

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

Code:

<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.

kether1 06-12-2011 06:19 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2206755)
You could do a condition to show code only to the user who posted it...

Code:

<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 [DATE]1307976670[/DATE] at [TIME]1307976670[/TIME] ---------------

Quote:

Originally Posted by kether1 (Post 2206759)
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

BirdOPrey5 06-13-2011 06:17 PM

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:


Code:

<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.

kether1 06-13-2011 06:29 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2207239)
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:


Code:

<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

BirdOPrey5 06-13-2011 06:42 PM

Quote:

Originally Posted by kether1 (Post 2207245)
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.

Code:

<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:

Code:

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

Bisha 06-13-2011 07:38 PM

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

Code:

       
          <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.

kether1 06-13-2011 07:51 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2207253)
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.

Code:

<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:

Code:

<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

BirdOPrey5 06-13-2011 10:28 PM

Quote:

Originally Posted by Bisha (Post 2207276)
Why, this code is now working for me on postbit_legacy template:

Code:

       
          <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.

Bisha 06-14-2011 08:58 AM

$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!

BirdOPrey5 06-14-2011 11:05 AM

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: https://vborg.vbsupport.ru/showthread.php?t=228078

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

Bisha 06-14-2011 04:32 PM

Thank you!

Mr_Running 06-15-2011 02:21 AM

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

Bisha 06-15-2011 09:08 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2207534)
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: https://vborg.vbsupport.ru/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!

BirdOPrey5 06-15-2011 10:54 PM

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.

Tautmann 06-17-2011 09:51 AM

Great! Thank you...

kether1 06-24-2011 02:11 PM

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:

Code:

<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

BirdOPrey5 06-24-2011 02:42 PM

Quote:

Originally Posted by kether1 (Post 2212201)
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:

Code:

<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:

Code:

<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.

kether1 06-24-2011 03:01 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2212221)
An else statement is if you want to display alternative information, an example would be:

Code:

<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?

BirdOPrey5 06-24-2011 03:43 PM

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:

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'] ?

kether1 06-24-2011 03:59 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2212246)
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:

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 [DATE]1308935315[/DATE] at [TIME]1308935315[/TIME] ---------------

Quote:

Originally Posted by BirdOPrey5 (Post 2212246)
In the template put this code:

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

BirdOPrey5 06-24-2011 04:55 PM

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.

Code:

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.


All times are GMT. The time now is 10:19 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04692 seconds
  • Memory Usage 1,875KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (33)bbcode_code_printable
  • (18)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete