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.

Hide Announcements in Certain Sections

3 posters

Go down

Hide Announcements in Certain Sections Empty Hide Announcements in Certain Sections

Post by Chelly March 21st 2017, 12:16 am

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

Posts : 48
Reputation : 1
Language : English

http://www.gasrforum.com/

Back to top Go down

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

Post by Draxion March 24th 2017, 10:28 am

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

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

https://www.talesoftellene.com/

Back to top Go down

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

Post by Chelly March 25th 2017, 12:07 am

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

Posts : 48
Reputation : 1
Language : English

http://www.gasrforum.com/

Back to top Go down

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

Post by Kyo Panda March 30th 2017, 4:39 pm

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.
Kyo Panda
Kyo Panda
Forumember

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

http://pt.rpgmaker.io

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum