2

In Drupal 7, I'm creating a large number (15+) of content types programmatically. There is one in particular that should never be promoted to the front page. It would be really nice if, by default, the box to do this was unchecked. I'm aware that this can be done through the front-end, but my goal is to make the web application as portable as possible. That is, other than content, I want it to be able to be moved completely and properly by only installing the correct modules.

I'm removing authoring information, for instance, by setting the variable node_submitted_{content type name} to FALSE. It would seem like there should be something like this available for promoting by default.

Thanks.

0

Whether nodes of a particular content type are promoted to the front page by default is stored in the Drupal array variable node_options_{content type name}:

$node_options = variable_get('node_options_{content type name}', array());
$promote_key = array_search('promote', $node_options);
if ($promote_key !== false) {
  unset($node_options[$promote_key]);
  variable_set('node_options_{content type name}', $node_options);
}
| improve this answer | |
0

BEWARE: when the node_options_{content type name} variable is not set a default is used that features the promote option.

so I needed to actually set the options just to 'status' that means published:

variable_set('node_options_drupal_projects', array('status'));
| 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.