how to hide comment box throw code

Events happening in the community are now at Drupal community events on www.drupal.org.
mayur.pimple's picture

Hi
im create cck field in content type.
in cck filed ,there is 2 option true/false

if true then comment form is enable and false then comment box disable.

Comments

Very easy. Use hook_nodeapi

amrit_b's picture

Very easy. Use hook_nodeapi (http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...) and catch the insert event.
Then, as per the selected option (true/false), set the $node->comment value.

Thanks

thanks

mayur.pimple's picture

thanks

It's can be done through hook_form_alter also.....

Tech_Musings's picture

It's can be done through hook_form_alter also by just using depending on your condition whether you want to disable the comment box then use unset($form['comment']);
Hope it will help some one.

thanks

CODE

mayur.pimple's picture

<?php

function hide_comment_form_alter(&$form, $form_state, $form_id)
{
global $node;
$node = node_load(arg(1));

switch ($node->type)
{

case 'page':

        unset($form['subject']);
        unset($form['comment_filter']);
        unset($form['submit']);
        unset($form['preview']); 

}
break;

}

Pune

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week