How to disable Form Comment plugin in details view

Mustafa_s

Member
Hello,

I'm currently using the Form Comment plugin (local commenting) to allow users to comment, this works pretty straight forward as you would expect. But I now want to be able to disable or hide either via CSS or Javascript the Form Comment in Details view, while keeping the ability to add comments in Form view.

The element ID for the form is form#master-comment-form so a simple CSS trick in template protostar-custom.css such as the following can hide this DIV id:

form#master-comment-form {
display: none;
}

But what the above CSS code does is it actually hides the comment form on all views, both Form and Details view. Knowing a trick I learned in the past while learning Fabrik, I tried the following CSS code to run the CSS code on Details view only:

.fabrikDetails form#master-comment-form {
display: none;
}

But for whatever the reason, this is not working. I thought about perhaps using the following Javascript code, to hide the element ID from a Details view URL, but unfortunately this doesn't work either:

var url = document.location.href;

if (url.indexOf('www.domain.com/fabrik/details/3/640') >= 0) {
$('form#master-comment-form').hide();
} else {
$('form#master-comment-form').show();
}

Lastly, I tried the good old Calc element to calculate on load and via ajax, but the following PHP code isn't hiding the element ID either. Boo.

var url = window.location.href;
if(url == "http://domain.com/fabrik/details/3/640")
{
document.getElementById('form#master-comment-form').style.display = 'none';

So I'm kinda stumped at this point as to how to proceed. If the Form Comment plugin was a regular Fabrik element I would not have trouble hiding it as it would be easy to use the built-in Javascript options to hide the element on load.

Is there any alternative way of achieving this? I want to be able to remove the ability to add comments in Details view by removing the form from Details view only.

Thank you.

 
Last edited:
Quick update on this, I managed to hide the ability to add comments from the Form Comment plugin in form view (new, edit) via the following javascript (onload):

document.getElementById("master-comment-form").style.visibility = "hidden";

While this hides the ability to add comments from the Form Comment plugin in form view, it doesn't hide it in details view. Strange as this method would have worked fine for regular Fabrik elements (non form plugin type).
 
When you say "the following javascript (onload)", how are you actually running it? With an element JS event, or through a form_X.js / details_X.js file?

-- hugh
 
A quick update on this issue in case someone else finds themselves with this requirement.

I downloaded and installed Custom CSS, with this custom module (in debug position) I was able to run the following CSS:

form#master-comment-form {
display: none;
}

The above CSS snippet will disable the comment plugin in Details view but keep it in Form view.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top