Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles

Reply
 
Thread Tools
vB4 Template Conditionals List
BBR-APBT's Avatar
BBR-APBT
Join Date: Feb 2009
Posts: 946

 

Maryland
Show Printable Version Email this Page Subscription
BBR-APBT BBR-APBT is offline 12-28-2009, 10:00 PM

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:
Code:
<vb:if condition="$show['member']">Show this to members only</vb:if>

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

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

Show one member:
Code:
<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:
Code:
<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:
Code:
<vb:if condition="can_moderate()">Show this to all moderators</vb:if>
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>

Show Moderator of current forum:
Code:
<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
Code:
<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
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>

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

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

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

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

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

vBulletin else if statement:
Code:
<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.
Reply With Quote
  #12  
Old 01-01-2010, 08:37 AM
Asterix_ita's Avatar
Asterix_ita Asterix_ita is offline
 
Join Date: Aug 2009
Location: Italy
Posts: 312
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ragtek View Post
$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
Reply With Quote
  #13  
Old 01-02-2010, 10:27 AM
MikeWarner's Avatar
MikeWarner MikeWarner is offline
 
Join Date: Nov 2001
Location: UK
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi - thanks for this post, however, can you provide conditionals for CMS sections please?
Reply With Quote
  #14  
Old 01-02-2010, 02:19 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MikeWarner View Post
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.
Reply With Quote
  #15  
Old 01-05-2010, 05:44 PM
abumohamed abumohamed is offline
 
Join Date: Mar 2005
Location: Saudi Arabia
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks
Reply With Quote
  #16  
Old 01-05-2010, 10:14 PM
hochun hochun is offline
 
Join Date: Dec 2009
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

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

Code:
{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 [DATE]1262737717[/DATE] at [TIME]1262737717[/TIME] ---------------

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


Code:
1. find showthread.php:2228 print_output($templater->render());
2. replace on
Code:
	$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!
Reply With Quote
  #17  
Old 01-07-2010, 09:12 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #18  
Old 01-08-2010, 04:03 AM
SledgeHead SledgeHead is offline
 
Join Date: Oct 2006
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #19  
Old 01-08-2010, 04:53 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SledgeHead View Post
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.
Reply With Quote
  #20  
Old 01-08-2010, 05:55 PM
putuajun's Avatar
putuajun putuajun is offline
 
Join Date: Dec 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

subscribed
Reply With Quote
  #21  
Old 01-08-2010, 07:11 PM
SledgeHead SledgeHead is offline
 
Join Date: Oct 2006
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BBR-APBT View Post
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.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:09 AM.


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.05401 seconds
  • Memory Usage 2,358KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (22)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (40)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete