enter image description here

I want to make hide WEBFORM particular content type programmatically in default / custom mode. Any help will be appreciable.


In your custom module disable it with :

function yourmodule_node_view($node, $view_mode){
    // if you want exclude you content type
    if($node->type =='yourcontenttype' && $view_mode=='yourdesireviewmode'){
    $node->content['webform']['enabled'] = FALSE;

for more details take look at hook_node_view and webform_node_view.

| improve this answer | |

Try implementing hook_node_view.Then you can put your condition on $node->type, access the webform with $node->webform and use $view_mode to load the current view mode.

| improve this answer | |

Got it after checking field module in core.

$bundle_settings = field_bundle_settings('node', $bundle);
  $viewmode = 'custom';
  $name = 'webform';
  $bundle_settings['extra_fields']['display']['webform']['custom'] = array(
    'weight' => 1,
    'visible' => TRUE / FALSE,
  field_bundle_settings('node', $bundle, $bundle_settings);

This will enable/disable field in specified view mode

| improve this answer | |

This handy module will do it as well and will give you some nice config options: https://www.drupal.org/project/rabbit_hole

From the project page: This works by providing multiple options to control what should happen when the entity is being viewed at its own page. You have the ability to

Deliver an access denied page. Deliver a page not found page. Issue a page redirect to any path or external url. Or simply display the entity (regular behavior).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.