vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Disable signatures in certain forums (https://vborg.vbsupport.ru/showthread.php?t=322721)

kerrghann 05-25-2016 02:45 AM

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.

cellarius 05-25-2016 04:34 AM

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.

kerrghann 05-25-2016 10:39 AM

Hmm. But for the second php code bit, the condition is saying AND. Wouldn't i essentially need to make that AND NOT?

MarkFL 05-25-2016 10:52 AM

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

cellarius 05-25-2016 11:23 AM

Quote:

Originally Posted by kerrghann (Post 2571320)
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 (Post 2571321)
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.

kerrghann 05-25-2016 12:50 PM

Thanks guys. This solved my problem. The hook definitely made this quick and painless. Much appreciated.

MarkFL 05-25-2016 01:31 PM

Quote:

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


All times are GMT. The time now is 11:23 AM.

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.01661 seconds
  • Memory Usage 1,755KB
  • 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
  • (2)bbcode_code_printable
  • (6)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete