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.

Enable/Disable Like feature according to sub-forums

3 posters

Go down

Enable/Disable Like feature according to sub-forums Empty Enable/Disable Like feature according to sub-forums

Post by Niko June 3rd 2023, 11:40 am

Coucou,

just a brief resource that @jucarese asked me, and that I am willing to share with everyone :wouhou:

Description

The tutorial allows you to decide on which subforums' topics the option to "Like/Dislike" can be enabled. If the topic is in a sub-forum not enabled to use the like option, this will be removed.

Installation: Javascript

You need to go towards Administration Control Panel (ACP) Modules HTML & Javascript Javascript codes management and create a new code - upon verifying that Javascript codes management is enabled.

  • Title: free choice - does not influence the code effect
  • Where: In topics
  • Code:
    Code:
    $(function() {
       /*
       Title: Enable/Disable Like feature according to sub-forums
       Author: Niko
       Version: 1.0
       Release Date: 03.06.2023 (dd.mm.year)
       Contact: https://www.fmcodes.net/u2
       Original content: https://www.fmcodes.net/t2036-
       */

        var enabled_forums = ['4','15','258']; //this is the only customization necessary

       const FORUM_VERSION = _userdata["tpl_used"];

       var breadcrumb_subforum = {
          'subsilver': 'table td.nav span.nav a.nav[href*="/f"]', //phpbb2
          'prosilver': '.topic-actions .pathname-box p a.nav[href*="/f"]', //phpbb3
          'punbb': '.pun-crumbs.noprint.clearfix span.crumbs a.nav[href*="/f"]', //punBB
          'invision': 'ul#navstrip li a.nav[href*="/f"]', //invision
          'modernbb': '.sub-header .sub-header-info .sub-header-path a + a', //modernBB
          'awesomebb': 'div#breadcrumbs.breadcrumbs-topic a+a' //awesomeBB
       };

       var like_block = {
          'subsilver': '.fa_like_div', //phpbb2
          'prosilver': '.fa_like_div', //phpbb3
          'punbb': '.fa_like_div', //punBB
          'invision': '.fa_like_div', //invision
          'modernbb': '.fa_like_div', //modernBB
          'awesomebb': '.fa_like_div' //awesomeBB
       };

        var subforum_path = $(breadcrumb_subforum[FORUM_VERSION]).attr('href');
        var forum_id = subforum_path.split('/f').pop().split('-')[0];

        if(enabled_forums.indexOf(forum_id) == -1) {
            $(like_block[FORUM_VERSION]).remove();
        }
    });


Customization

You only have to customize the content of the variable
Code:
var enabled_forums = ['4','15','258'];
with the subforum IDs where you want to enable the like/dislike option. Any forum with an ID not in this list, will have the option remove.

The example will allow sub-forums with IDs 4 -15 and 258 to have the like feature. A topic in the sub forum with ID 27 will have the like feature removed from all its posts and topics. Razz

Enable/Disable Like feature according to sub-forums Scree143
Niko
Niko
Helper
Helper

Male Posts : 3106
Reputation : 244
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

skouliki, SLGray, SarkZKalie, TonnyKamper, jucarese, Obscure and Razor12345 like this post

Back to top Go down

Enable/Disable Like feature according to sub-forums Empty Re: Enable/Disable Like feature according to sub-forums

Post by skouliki June 3rd 2023, 1:35 pm

this is handy
thank you
skouliki
skouliki
Manager
Manager

Female Posts : 15118
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Niko likes this post

Back to top Go down

Enable/Disable Like feature according to sub-forums Empty Re: Enable/Disable Like feature according to sub-forums

Post by Niko June 3rd 2023, 1:56 pm

Glad you appreciate @skouliki loove ùù
Niko
Niko
Helper
Helper

Male Posts : 3106
Reputation : 244
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

skouliki likes this post

Back to top Go down

Enable/Disable Like feature according to sub-forums Empty Re: Enable/Disable Like feature according to sub-forums

Post by TonnyKamper June 3rd 2023, 4:04 pm

Awesome  @Niko  just what I need for my official forum loove
TonnyKamper
TonnyKamper
Active Poster

Female Posts : 1047
Reputation : 78
Language : Dutch/English
Location : DSF Admin

http://www.nederlandheelt.nl/forum

skouliki and Niko like this post

Back to top Go down

Enable/Disable Like feature according to sub-forums Empty Re: Enable/Disable Like feature according to sub-forums

Post by Niko June 3rd 2023, 6:33 pm

@TonnyKamper glad you'll enjoy it loul
Niko
Niko
Helper
Helper

Male Posts : 3106
Reputation : 244
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

TonnyKamper likes this post

Back to top Go down

Back to top

- Similar topics

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