User login

Create 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);
}
?>

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.