The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
3 posters

    Hide Announcements in Certain Sections

    Chelly
    Chelly
    Forumember


    Posts : 48
    Reputation : 1
    Language : English

    Hide Announcements in Certain Sections Empty Hide Announcements in Certain Sections

    Post by Chelly Tue 21 Mar 2017 - 0:16

    Is there a way to hide global announcements in certain sections of the forum?

    There are sections we are turning into blogs and would like to remove the global announcements from being visible in them.
    Draxion
    Draxion
    Helper
    Helper


    Male Posts : 2518
    Reputation : 321
    Language : English
    Location : USA

    Hide Announcements in Certain Sections Empty Re: Hide Announcements in Certain Sections

    Post by Draxion Fri 24 Mar 2017 - 10:28

    Hi there,

    Yes, I believe it's possible with JavaScript since you have to target the specific page when the user loads it up instead of having CSS target the entire forum.
    Chelly
    Chelly
    Forumember


    Posts : 48
    Reputation : 1
    Language : English

    Hide Announcements in Certain Sections Empty Re: Hide Announcements in Certain Sections

    Post by Chelly Sat 25 Mar 2017 - 0:07

    Couldn't I just use CSS in the blog template to hide announcements that way?

    If not, is there a script that already exists that I can use?
    Kyo Panda
    Kyo Panda
    Forumember


    Male Posts : 33
    Reputation : 19
    Language : Portuguese, English
    Location : Brazil

    Hide Announcements in Certain Sections Empty Re: Hide Announcements in Certain Sections

    Post by Kyo Panda Thu 30 Mar 2017 - 16:39

    Try adding to a new Javascript with Placement set to In the sub-forums:

    Code:
    (function($) {
       'use strict';
       
       if (!/^\/f\d+-/i.test(location.pathname)) {
          return;
       }
       
       var config = {
          forums: [1, 25],
          query: [
             'Important',
             'Sticky',
          ]
       };
       
       var fid = ~~location.pathname
          .split('/f')
          .pop()
          .split('-')
          .shift()
       ;
       
       if (config.forums.indexOf(fid) === -1) {
          return;
       }
       
       var query = [];
       
       $.each(config.query, function() {
          query.push('.topic-type:contains("' + this + '")');
       });
       
       $(function() {
          $(query.join(', ')).closest('tr').css('display', 'none');
       });
    }(jQuery));

    In this part you can configure which forums will have the announcements hidden:

    Code:
    var config = {
       forums: [1, 25],
       query: [
          'Important',
          'Sticky',
       ]
    };

    • forums is the list of IDs of the forums to have announcements hidden.
    • query is what kind of topics will be hidden.

    ---

    You have a beautiful forum, btw.

      Current date/time is Mon 11 Nov 2024 - 18:02