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)

jschvili 03-16-2011 01:56 PM

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

<vb:if condition="$vbulletin->GPC['forumid'] == 37">
What shall I change/add to to make this happend? Thanks!

BirdOPrey5 03-16-2011 02:16 PM

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

Code:

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

jschvili 03-16-2011 02:32 PM

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-li...ng-av-led.html

What do you think?

BirdOPrey5 03-16-2011 02:42 PM

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

Try one of these...

Code:

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

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

jschvili 03-16-2011 02:58 PM

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

Any other suggestions? ;-)

BirdOPrey5 03-16-2011 03:33 PM

Hmmm...

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

Code:

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

jschvili 03-16-2011 03:43 PM

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

ALBCODERS 03-17-2011 10:42 AM

Quote:

Originally Posted by Alp Ozdemir (Post 1991194)
Try this;

Code:

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


Tnakyou this one works perfect
;) eyvallah

Hawk7173 03-23-2011 05:54 AM

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>

BirdOPrey5 03-23-2011 11:18 AM

Quote:

Originally Posted by Hawk7173 (Post 2176457)
I tried this code, but for some reason it does not work

Code:

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

Code:

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


Hawk7173 03-23-2011 09:15 PM

It was posted in forumdisplay

Thanks

Footman 03-24-2011 11:45 AM

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

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

<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

BirdOPrey5 03-24-2011 12:21 PM

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

Code:

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

Footman 03-25-2011 07:48 PM

Quote:

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

BirdOPrey5 03-25-2011 09:49 PM

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.

Bisha 03-27-2011 08:24 PM

What is Conditional tag for post count!

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

BirdOPrey5 03-27-2011 09:31 PM

Quote:

Originally Posted by Bisha (Post 2178096)
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:

Code:

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

Code:

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


Lynne 03-27-2011 09:36 PM

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

BirdOPrey5 03-27-2011 09:50 PM

Quote:

Originally Posted by Lynne (Post 2178116)
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.

Lynne 03-28-2011 04:03 AM

Quote:

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

Bisha 03-28-2011 12:42 PM

Thank you both :)

The second is ok in my case!

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

:)

BirdOPrey5 03-28-2011 01:42 PM

Quote:

Originally Posted by Lynne (Post 2178215)
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.)

attroll 04-02-2011 12:27 AM

I am trying to find the new conditions for VB4.

Old condistion:
Code:

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

<vb:if condition="$today_is_wednesday">Test</vb:if>
Any ideas?

BirdOPrey5 04-02-2011 01:56 AM

Try:
Code:

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


attroll 04-02-2011 02:26 AM

Quote:

Originally Posted by BirdOPrey5 (Post 2179953)
Try:
Code:

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

<vb:if condition="gmdate('D') == 'Wed' ">
<b>Tonight is a chat night, Scheduled time is 8 pm.</b><br>
</vb:if>


BirdOPrey5 04-02-2011 01:10 PM

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

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

karlm 04-14-2011 07:53 AM

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.

HMBeaty 04-14-2011 07:55 AM

Quote:

Originally Posted by karlm (Post 2184487)
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....
HTML Code:

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

karlm 04-14-2011 08:14 AM

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

HMBeaty 04-14-2011 08:20 AM

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

Bisha 04-14-2011 05:53 PM

One more thing...

how to do a OR condition.

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

BirdOPrey5 04-14-2011 05:56 PM

Quote:

Originally Posted by Bisha (Post 2184680)
One more thing...

how to do a OR condition.

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

it's...

Code:

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

Bisha 04-14-2011 06:08 PM

Thank you BirdOPrey5

:)

Alan_SP 04-18-2011 02:31 PM

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:

Code:

<vb:if condition="$post['usergroupid'] == 6">
Any idea how BBcode use could be restricted only to certain usergroups?

BirdOPrey5 04-18-2011 08:14 PM

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

There is a mod, "Advanced BB Code Manager" 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.

Alan_SP 04-19-2011 09:30 PM

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

Lpspider 04-19-2011 10:18 PM

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

StarBuG 04-30-2011 11:27 AM

Some more conditions you can add to your list:

Show only if vBulletin notices are not shown
Code:

<vb:if condition="!$show['notices']">
</vb:if>

For use in template navbar: Show only in Forum ID X
Code:

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

BirdOPrey5 05-03-2011 04:30 PM

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:

Code:

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

Hasanudin 05-26-2011 01:16 PM

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>


All times are GMT. The time now is 07:07 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.04734 seconds
  • Memory Usage 1,841KB
  • 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
  • (24)bbcode_code_printable
  • (1)bbcode_html_printable
  • (10)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