Home ›
Create a nodequeue programaticallyCreate a nodequeue programatically
In your hook_install() and/or hook_update_N() implementation, this sort of code will create a new nodequeue (if it already exists, you'll only get database errors, though this could be worked around with a bit more code if for some reason you couldn't rely on what the site you are updating has or not).
The nodequeue definition comes from a normal nodequeue export, or at least, it will be normal once this patch is committed. (Import and export would be even better if nodequeue stopped using the numeric queue ID internally and used the machine name it already has, but at least this makes making hook_update_N functions easy.)
<?php
/**
* Implements hook_install().
*/
function example_install() {
$nodequeue = new stdClass;
$nodequeue->api_version = 2;
$nodequeue->name = 'recommended';
$nodequeue->title = 'Recommended content';
$nodequeue->subqueue_title = '';
$nodequeue->size = 0;
$nodequeue->link = 'Add to recommended';
$nodequeue->link_remove = 'Remove from recommended';
$nodequeue->owner = 'nodequeue';
$nodequeue->show_in_ui = 1;
$nodequeue->show_in_tab = 1;
$nodequeue->show_in_links = 1;
$nodequeue->reference = '0';
$nodequeue->reverse = 1;
$nodequeue->i18n = 0;
$nodequeue->roles = array();
$nodequeue->types = array(
0 => 'article',
1 => 'page',
2 => 'news',
3 => 'project',
);
$nodequeue->add_subqueue = array(
1 => 'Recommended content',
);
nodequeue_save($nodequeue);
}
?>More like this
- Nodequeues for developers | computerminds
- Adding fields to a content type programatically in Drupal 7
- Copy a worklow-ng workflow to do same actions on create content as update
- Capturing Menu Block configuration in code with hook_menu_block_blocks()
- Creating “Simple” Drupal Modules, and Filling the Functionality Gap


Comments
Post new comment