- /
- /
Universally Prevent Drupal Nodes from being "Promoted to front page"
Drupal content forms have a field in the Publishing section labeled as "Promoted to front page". This is a convenience feature that allows you to easily mark nodes to appear on your site's homepage, but you may not necessarily want to manage your content this way. It's easy enough to change the default for this in each content type's administration form, but how can you ensure that nodes are never placed in this state?
Here is a very simple process for D6 to ensure that no nodes, or only those nodes that you specify, are Promoted to front page:
- In your site's custom module, implement "hook_nodeapi"
API documentation for hook_nodeapi - Within this function, capture the "presave", "update" and "insert" operations. This is commonly done via a "switch" control block.
- For each of these operations, simply set the "promote" property to 0
- If this is the first time your module implements "hook_nodeapi", be sure to flush your cache
This is how the code will appear; obviously replace "MYMODULE" with your module's name.
function MYMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch($op){
case 'presave':
case 'insert':
case 'update':
$node->promote = 0;
break;
}
}
This code can be enhanced to check for specific users, node types, or any other criteria such that you can control which nodes are affected or not.
