Enable/Disable Like feature according to sub-forums
3 posters
Page 1 of 1
Enable/Disable Like feature according to sub-forums
Coucou,
just a brief resource that @jucarese asked me, and that I am willing to share with everyone
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.
just a brief resource that @jucarese asked me, and that I am willing to share with everyone

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

skouliki, SLGray, SarkZKalie, TonnyKamper, jucarese, Obscure and Razor12345 like this post
Re: Enable/Disable Like feature according to sub-forums
Awesome @Niko just what I need for my official forum 

skouliki and Niko like this post
TonnyKamper likes this post

» How I Enable The Viewing Feature?
» How to enable/disable signatures
» Disable/enable signatures
» how can i Enable and disable the avatar
» When I enable portal to be the homepage of my forums, members can't access the forums themselves
» How to enable/disable signatures
» Disable/enable signatures
» how can i Enable and disable the avatar
» When I enable portal to be the homepage of my forums, members can't access the forums themselves
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum