Hide some topics via script?
3 posters
Page 1 of 1
Hide some topics via script?
Hi all,
Is there any script to hide some topics under some forums?
I know the procedure to hide a category or forum but not for topics...
Thanks,
Is there any script to hide some topics under some forums?
I know the procedure to hide a category or forum but not for topics...
Thanks,
Last edited by betclever on November 11th 2014, 7:59 pm; edited 1 time in total
Re: Hide some topics via script?
Hello bet clever,
See if this is what you want :
Administration Panel > Modules > JavaScript codes management > Create a new script
Title : Your choice
Placement : In all the pages
Paste the code below :
Its function is to hide the link to the topic, if it contains the topic id. In the script you'll write : hideTopic(id);
id : the id of the topic. Example https://help.forumotion.com/t136620-hide-some-topics-via-script
/t136620 is where the id is, so to hide this topic's link I'd write :
See if this is what you want :
Administration Panel > Modules > JavaScript codes management > Create a new script
Title : Your choice
Placement : In all the pages
Paste the code below :
- Code:
$(function() {
hideTopic(1);
function hideTopic(id) {
var a = document.getElementsByTagName('A'), reg = new RegExp('/t'+id),i;
for (i=0; i<a.length; i++) if (reg.test(a[i].href)) a[i].style.display = 'none';
}
});
Its function is to hide the link to the topic, if it contains the topic id. In the script you'll write : hideTopic(id);
id : the id of the topic. Example https://help.forumotion.com/t136620-hide-some-topics-via-script
/t136620 is where the id is, so to hide this topic's link I'd write :
- Code:
hideTopic(136620);
Re: Hide some topics via script?
Thanks Ange tuteur but I forgot to say that I just want to hide some topics for guest users but for members, these ones have to be apparent.
Is this possible?
Is this possible?
Re: Hide some topics via script?
See if this works :
I added a condition to the top of the script.
- Code:
$(function() { if (_userdata.user_id != -1) return
hideTopic(1);
function hideTopic(id) {
var a = document.getElementsByTagName('A'), reg = new RegExp('/t'+id),i;
for (i=0; i<a.length; i++) if (reg.test(a[i].href)) a[i].style.display = 'none';
}
});
I added a condition to the top of the script.
Re: Hide some topics via script?
Oh super!!!
I will try it as quickly as possible and keep you informed.
Thanks a lot!
I will try it as quickly as possible and keep you informed.
Thanks a lot!
Re: Hide some topics via script?
I got a question Ange tuteur.
How can I regroup in one script several topics to hide?
Shall I copy-paste each time the same code you have mentionned for each topic I want to hide or just a phrase?
Thanks,
How can I regroup in one script several topics to hide?
Shall I copy-paste each time the same code you have mentionned for each topic I want to hide or just a phrase?
Thanks,
Re: Hide some topics via script?
You can copy and paste hideTopic(); as much as you want.
Here is an example :
Here is an example :
- Code:
$(function() { if (_userdata.user_id != -1) return
hideTopic(1);
hideTopic(2);
hideTopic(3);
hideTopic(4);
hideTopic(5);
function hideTopic(id) {
var a = document.getElementsByTagName('A'), reg = new RegExp('/t'+id),i;
for (i=0; i<a.length; i++) if (reg.test(a[i].href)) a[i].style.display = 'none';
}
});
Re: Hide some topics via script?
Hi,
Is there any possibility to view the topic for members however for guest users hide the analyses or the text inside the topics?
It will be great if I can leave a message to guest users to ask guests to register to view the content of this topic...
I don't know if it's possible of course but maybe add a condition like the one you have mentioned here:
Is there any possibility to view the topic for members however for guest users hide the analyses or the text inside the topics?
It will be great if I can leave a message to guest users to ask guests to register to view the content of this topic...
I don't know if it's possible of course but maybe add a condition like the one you have mentioned here:
- Code:
{ if (_userdata.user_id != -1)
Re: Hide some topics via script?
So you want to hide the content of messages for guests ? Like this :
Script :
Placement : In the topics
The variable guestText is the content displayed to guests when they're logged out. You can change this anyway you want.
Script :
Placement : In the topics
- Code:
$(function() {
var guestText = '<span style="color:#F00">Please <a href="/login">login</a> or <a href="/register">register</a> to see this content.</span>',
a = document.getElementsByTagName('DIV'),i;
if (_userdata.user_id === -1) for (i=0; i<a.length; i++) if (/postbody/.test(a[i].parentNode.parentNode.className)) a[i].innerHTML = guestText;
});
The variable guestText is the content displayed to guests when they're logged out. You can change this anyway you want.
Re: Hide some topics via script?
Ok super but where shall I put this script ?
I don't want to put this one for all topics but only for some topics?
Shall I put this script in the topic description or under scripts on the CP?
Thanks Ange tuteur
I don't want to put this one for all topics but only for some topics?
Shall I put this script in the topic description or under scripts on the CP?
Thanks Ange tuteur
Re: Hide some topics via script?
Okay, try this :
Administration Panel > Modules > JavaScript codes management > Create a new script
Title : your choice
Placement : In the topics
Paste the code below :
I added an array for topic ids :
Where the numbers are, is where you'll write the IDs of the topics you want the script to run in. You can add as many as you want, so long as the IDs are separated by commas.
Administration Panel > Modules > JavaScript codes management > Create a new script
Title : your choice
Placement : In the topics
Paste the code below :
- Code:
$(function() {
var guestText = '<span style="color:#F00">Please <a href="/login">login</a> or <a href="/register">register</a> to see this content.</span>',
topics = [1, 2, 3, 4, 5, 6],
a = document.getElementsByTagName('DIV'),i,j;
if (_userdata.user_id === -1) for (j=0; j<topics.length; j++) if (topics[j] === Number(window.location.pathname.replace(/\/t(\d+).*/,'$1'))) for (i=0; i<a.length; i++) if (/postbody/.test(a[i].parentNode.parentNode.className)) a[i].innerHTML = guestText;
});
I added an array for topic ids :
- Code:
topics = [1, 2, 3, 4, 5, 6]
Where the numbers are, is where you'll write the IDs of the topics you want the script to run in. You can add as many as you want, so long as the IDs are separated by commas.
Similar topics
» Hide effect for similar topics script
» How to put this script for some topics
» Show/hide script not working
» is there a recent topics with auto update Script
» the Script Warning for Locked Topics is not working for some reason
» How to put this script for some topics
» Show/hide script not working
» is there a recent topics with auto update Script
» the Script Warning for Locked Topics is not working for some reason
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum