Quantcast
Channel: Open Data - Nodequeue
Viewing all articles
Browse latest Browse all 2

Create a nodequeue programatically

$
0
0

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

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images