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)

ICannt.org 06-28-2010 06:40 AM

Quote:

Originally Posted by BBR-APBT (Post 1941139)
Show is every forum but one: Remember to change x
Code:

<vb:if condition="$forum[forumid] != x">Show this if forum id is not x</vb:if>

Show in several forums:
Code:

<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

egyptsons 06-28-2010 11:19 AM

Quote:

Originally Posted by ICannt.org (Post 2060895)
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

BirdOPrey5 06-30-2010 02:30 AM

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.

kether1 07-12-2010 08:07 PM

subscribe.
K

RobbieZ 07-14-2010 09:36 AM

Show Moderator of one forum: Remember to change x
Code:

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

ubcforums 07-15-2010 06:12 PM

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

Thanks :)

BirdOPrey5 07-15-2010 06:45 PM

Quote:

Originally Posted by ubcforums (Post 2069616)
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

Code:

<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

ubcforums 07-17-2010 11:40 AM

Quote:

Originally Posted by BirdOPrey5 (Post 2069640)
Edit the postbit (or postbit_legacy) and add

Code:

<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

BirdOPrey5 07-17-2010 03:16 PM

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.

ubcforums 07-17-2010 05:47 PM

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

fitnesshealth 07-26-2010 11:49 PM

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?

BirdOPrey5 07-27-2010 01:05 AM

Quote:

Originally Posted by fitnesshealth (Post 2075012)
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:

Code:

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


fitnesshealth 07-27-2010 06:41 AM

Thanks, works great!

encryption 07-31-2010 08:11 PM

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

ICannt.org 08-07-2010 06:40 AM

Quote:

Originally Posted by ICannt.org (Post 2060895)
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

adom7 08-07-2010 10:54 AM

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?

Lynne 08-07-2010 02:24 PM

Quote:

Originally Posted by ICannt.org (Post 2080415)
Any idea on this?
Cheers

HTML Code:

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

Quote:

Originally Posted by adom7 (Post 2080470)
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.

adom7 08-07-2010 05:09 PM

Quote:

Originally Posted by Lynne (Post 2080525)

Quote:

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.

Come2Daddy 08-11-2010 05:47 PM

Beautiful :)

XLCR GODFATHER 08-13-2010 08:02 PM

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

Code:

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

I tried
Code:

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

<vb:if condition="$post['fieldx']">
or is there something I am missing else where?

Thank you in advance for any help....

nymyth 08-19-2010 01:00 PM

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?

BirdOPrey5 08-19-2010 03:31 PM

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>

nymyth 08-19-2010 08:08 PM

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

BirdOPrey5 08-19-2010 08:46 PM

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.

ICannt.org 08-25-2010 11:03 AM

So in the template FORUMDISPLAY I've done this:
Code:

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

tech4c 08-25-2010 02:15 PM

thanks

BirdOPrey5 08-25-2010 07:24 PM

Quote:

Originally Posted by ICannt.org (Post 2089294)
So in the template FORUMDISPLAY I've done this:
Code:

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

Code:

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

ICannt.org 08-28-2010 06:37 AM

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

BirdOPrey5 08-28-2010 01:39 PM

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

ICannt.org 08-29-2010 03:10 AM

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.

BirdOPrey5 08-29-2010 04:58 PM

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.

ICannt.org 08-31-2010 10:32 PM

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

midnz 09-02-2010 08:37 AM

Quote:

Originally Posted by ICannt.org (Post 2090948)
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)
PHP Code:

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' ) ;



moonclamp 09-03-2010 12:46 AM

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

HTML Code:

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

BirdOPrey5 09-03-2010 01:48 AM

Try

Code:

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


moonclamp 09-03-2010 04:17 AM

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

BirdOPrey5 09-03-2010 01:38 PM

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.

XLCR GODFATHER 09-03-2010 02:18 PM

try

Code:

$userinfo['fieldxx']
worked for me

moonclamp 09-03-2010 03:54 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2093269)
it may be something like $vboptions->bbuserinfo['fieldX']

I tried that one to no avail.
Quote:

Originally Posted by BirdOPrey5 (Post 2093269)
or even $this->registry->bbuserinfo['fieldX']

I'll have a go with the above a bit later (when nobody is on my site), thanks :)

Quote:

Originally Posted by XLCR GODFATHER (Post 2093289)
try

Code:

$userinfo['fieldxx']
worked for me

Already tried that, and unfortunately it didn't do it.

ICannt.org 09-04-2010 04:58 AM

Quote:

Originally Posted by midnz (Post 2092716)
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. :)


All times are GMT. The time now is 02:32 PM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03784 seconds
  • Memory Usage 1,847KB
  • 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
  • (15)bbcode_code_printable
  • (2)bbcode_html_printable
  • (1)bbcode_php_printable
  • (16)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