Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 05-25-2016, 02:45 AM
kerrghann's Avatar
kerrghann kerrghann is offline
 
Join Date: Jul 2012
Location: Hawaii
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Disable signatures in certain forums

I would like to disable signatures in certain forums, I attempted to add this to my postbit_legacy (of which my forum is set to use) but I may be doing it wrong. I have tried two methods:


This one
Code:
				<vb:if condition="$post['signature'] AND $GLOBALS[forumid] != 421 || 578 || 680 || 638 || 597 || 36 || 246 || 247 || 490 || 250 || 531 || 748 || 742 || 740 || 744 || 129 || 769 || 772 || 770 || 771 || 691 || 711 || 712 || 713 || 714 || 715 || 716 || 696 || 717 || 718 || 719 || 750 || 751 || 752 || 753 || 754 || 779 || 720 || 778 || 721 || 722 || 723 || 763 || 767 || 764 || 765 || 776 || 777">
		<!-- sig -->
					<blockquote class="signature restore"><div class="signaturecontainer">{vb:raw post.signature}</div></blockquote>
				</vb:if>

And This One
Code:
				<vb:if condition="$post['signature'] AND $GLOBALS[forumid] != 421,578,680,638,597,36,246,247,490,250,531,748,742,740,744,129,769,772,770,771,691,711,712,713,714,715,716,696,717,718,719,750,751,752,753,754,779,720,778,721,722,723,763,767,764,765,776,777">
		<!-- sig -->
					<blockquote class="signature restore"><div class="signaturecontainer">{vb:raw post.signature}</div></blockquote>
				</vb:if>
Neither seem to be working. Signatures show up in all forums.

NOTE: I have also cleared cache and used the maintenance tool for emptying signature cache.
Reply With Quote
  #2  
Old 05-25-2016, 04:34 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't chain conditions like that in PHP. Template conditions are basically transferred to PHP, so its basic rules apply.

You either need to do
PHP Code:
$GLOBALS[forumid] != AND $GLOBALS[forumid] != AND $GLOBALS[forumid] != 
and so on. More elegant:

PHP Code:
<if condition="i$post['signature'] AND !in_array($GLOBALS['forumid'], array(1,2,3))"
BTW: OR condition will not work when adding up negative conditions. If you do "not in 1 OR not in 2 OR not in 3", then the condition will always be true. If it is 1, it is not 2 or 3, and if its 2, it's not 1 or 3.
Reply With Quote
  #3  
Old 05-25-2016, 10:39 AM
kerrghann's Avatar
kerrghann kerrghann is offline
 
Join Date: Jul 2012
Location: Hawaii
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm. But for the second php code bit, the condition is saying AND. Wouldn't i essentially need to make that AND NOT?
Reply With Quote
  #4  
Old 05-25-2016, 10:52 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What I would do is create a plugin hooked at "postbit_display_complete" with the code:

PHP Code:
if (in_array($forum['forumid'], array(421,578,680,638,597,36,246,247,490,250,531,748,742,740,744,129,769,772,770,771,691,711,712,713,714,715,716,696,717,718,719,750,751,752,753,754,779,720,778,721,722,723,763,767,764,765,776,777)))
{
    
$post['signature'] = '';

The advantage to using a plugin vs. a template edit is that it will work for all styles and will work whether you use "postbit" or "postbit_legacy" and it can easily be enabled/disabled.
Reply With Quote
Благодарность от:
cellarius
  #5  
Old 05-25-2016, 11:23 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kerrghann View Post
Hmm. But for the second php code bit, the condition is saying AND. Wouldn't i essentially need to make that AND NOT?
Sorry, typo. It needs to be !in_array (note the !).

--------------- Added [DATE]1464182800[/DATE] at [TIME]1464182800[/TIME] ---------------

Quote:
Originally Posted by MarkFL View Post
What I would do is create a plugin hooked at "postbit_display_complete" with the code:

PHP Code:
if (in_array($forum['forumid'], array(421,578,680,638,597,36,246,247,490,250,531,748,742,740,744,129,769,772,770,771,691,711,712,713,714,715,716,696,717,718,719,750,751,752,753,754,779,720,778,721,722,723,763,767,764,765,776,777)))
{
    
$post['signature'] = '';

The advantage to using a plugin vs. a template edit is that it will work for all styles and will work whether you use "postbit" or "postbit_legacy" and it can easily be enabled/disabled.
You're absloutely right. Although I'd do
PHP Code:
$show['signature'] = false
inside the condition. But that's nitpicking.
Reply With Quote
  #6  
Old 05-25-2016, 12:50 PM
kerrghann's Avatar
kerrghann kerrghann is offline
 
Join Date: Jul 2012
Location: Hawaii
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks guys. This solved my problem. The hook definitely made this quick and painless. Much appreciated.
Reply With Quote
  #7  
Old 05-25-2016, 01:31 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cellarius View Post
...You're absloutely right. Although I'd do
PHP Code:
$show['signature'] = false
inside the condition. But that's nitpicking.
Good call...if I had noticed that, I would have suggested it as well.
Reply With Quote
Reply

Thread Tools
Display Modes

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 12:03 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.08859 seconds
  • Memory Usage 2,251KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (6)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (1)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete