14

Two possible methods that I have explored:

Use hook_form_alter to unset both options on node edit forms. But on the main admin content page, the options still appear under 'Update options' dropdown.

Use Override Node Options module. This provides granular control, but it means disabling the 'Administer content' permission. Users then can't see the 'Update options' at all, which they still need in order to bulk publish, delete, etc.

16

There are 3 places, where those options can be seen:

  • on admin/structure/types/manage/article, for the "Article" content type

    screenshot

  • on node/2/edit, for the node with ID equal to 2

    screenshot

  • on admin/content, between the "Update options"

    screenshot

If you need to remove the options from those setting/administrative pages, then you need to alter the following form builders:

node_admin_nodes() is the form builder for the node administration overview in admin/content, which includes the "Update options" field that allows the users with the right permission to promote/demote a node from the front page, and to make a node sticky. The field lists all the node operations implemented by modules; in the list of the operations obtained with $operations = module_invoke_all('node_operations'), those operations are represented from $operations['promote'], $operations['demote'], $operations['sticky'], and $operations['unsticky'].

13

Here is a custom module I wrote for Drupal 7 that removes "promote to front page" and "sticky at top of lists" on node add/edit forms, content type add/edit forms and the admin/content dropdown. This module does not alter any database settings so it won't change existing content, you can always disable it and get your options back and everything will work just like it did before.

Paste this code into a hide_sticky_promote.module and make a corresponding hide_sticky_promote.info file, enable module and wallah, no more sticky and promote checkboxes or dropdown selections.

/**
 * Remove sticky/promote entirely from add and edit content type forms.
 *
 * Implements hook_form_FORM_ID_alter().
 */
function hide_sticky_promote_form_node_type_form_alter(&$form, &$form_state, $form_id) {
  // Remove sticky/promote entirely from add and edit content type forms.
  $options = array('promote', 'sticky');
  foreach ($options as $key) {
    unset($form['workflow']['node_options']['#options'][$key]);    
  }
}

/**
 * Remove sticky/promote entirely from node/X/edit & node/X/add forms.
 * 
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function hide_sticky_promote_form_node_form_alter(&$form, &$form_state, $form_id) {
  $options = array('promote', 'sticky');
  foreach ($options as $key) {
    $form['options'][$key]['#access'] = FALSE;
  }
}

/**
 * Remove some sticky/promote update options on admin/content.
 *
 * Implements hook_form_FORM_ID_alter().
 */
function hide_sticky_promote_form_node_admin_content_alter(&$form, &$form_state, $form_id) {
  $options = array('demote', 'promote', 'sticky', 'unsticky', );
  foreach ($options as $key) {
    unset($form['admin']['options']['operation']['#options'][$key]);
  }
}

Or grab it from here in module form: https://github.com/StudioZut/hide-sticky-promote

3

Use the following:

/**
 * Implements hook_form_alter().
 * This is remove the promote to frontpage, and make sticky options from node edit pages
 */
function alter_drupal_form_alter(&$form, &$form_state, $form_id) {
  if (strpos($form_id, '_node_form') !== FALSE) {
    unset($form['options']['sticky']);
    unset($form['options']['promote']);
  }

  if (strpos($form_id, 'node_admin_content') !== FALSE) {
    //$opt[''] = '- Select -';
    $opt['publish'] = 'Publish selected content'; 
    $opt['unpublish'] = 'Unpublish selected content'; 
    $opt['delete'] = 'Delete selected content'; 
    $opt['pathauto_update_alias'] = 'Update URL alias'; 
    $form['admin']['options']['operation']['#options'] = $opt;


    // print_r($form['admin']['options']['operation']['#options']);
  }
}
2

In Drupal 8, the option can be disabled per content type:

/admin/structure/types/manage/page/form-display

The "node operation bulk form" field must also be modified in the admin content view to remove the corresponding action from /admin/content

/admin/structure/views/view/admin_content

If wanting to keep the content type promoting options, for usage with custom views for example, the view "frontpage" that generate the frontpage page can also be modified in

/admin/structure/views/view/frontpage

Adding for example an extra filter 'is not equal to promoted' and removing the "no result behaviour" " makes that view returning no results.

1

You can disable the 'promote to front page' by editing the content type. To hide it and/or the 'sticky' options, revisions and more, check out the Jammer module for Drupal 7.

0

Why don't make a different template region that only appears on the front page and remove the ['content'] region on that page ?

Elements on forms can be hidden using css or with hook_preprocess_form()

0

I use the "Promote Disable" module for this.

It creates a control at Configuration -> Content authoring -> Promote disable that gives a select list of all your content types. Ctrl/multi-select items in the list to remove the promote option entirely.

0
function HOOK_form_node_form_alter(&$form, FormStateInterface $form_state) {
  if (isset($form['promote'])) {
    unset($form['promote']);
  }

  if (isset($form['sticky'])) {
    unset($form['sticky']);
  }
}

It only needs above

-1

I suspect you could implement a hook_node_presave and set those to 0. This should override any possible way to set these.

You could also try to hook_form_alter the form used on that admin page and remove those options.

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.