Feed Icon Twitter Icon Druplicon Facebook icon Xing icon Linkedin icon Foursquare icon Last.fm icon Last.fm icon Slideshare icon

Drupal View - Unpublished Content

On some of my websites I use to write content without publishing it right away. Thus I often create a custom view that displays imcomplete (i.e. unpublished) nodes inside a block that is only visible for me and other Administrators. This block includes a direkt edit link to every unpublished node, which makes it easy to access and directly edit your content drafts.

Of course this view can also be extended by using taxonomy filters via url arguments or by creating a page view that displays content filtered or sorted by author.

Here we go: Import this view into your Drupal website (using the Views module, of course):

$view = new view;
$view->name = 'unpublished';
$view->description = 'Unpublished content';
$view->tag = 'content';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Standards', 'default');
$handler->override_option('fields', array(
'title' => array(
'label' => '',
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'edit_node' => array(
'label' => '',
'text' => '[edit]',
'exclude' => 0,
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'last_updated' => array(
'order' => 'DESC',
'granularity' => 'second',
'id' => 'last_updated',
'table' => 'node_comment_statistics',
'field' => 'last_updated',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => 0,
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'role',
'role' => array(
'3' => 3,
),
));
$handler->override_option('title', 'Unpublished content');
$handler->override_option('empty', 'There\'s no unpublished content available.');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 5);
$handler->override_option('use_pager', 'mini');
$handler->override_option('use_more', 1);
$handler->override_option('row_options', array(
'inline' => array(
'title' => 'title',
'edit_node' => 'edit_node',
),
'separator' => ' | ',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', 'Unpublished content');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('page', 'Seite', 'page_1');
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'teaser' => 1,
'links' => 1,
'comments' => 0,
));
$handler->override_option('path', 'admin/content/unpublished');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));

Please leave a comment if you have other ideas on how to extend this view, to probably make it a useful tool for moderating your unpublished content.

Comments

Thank you, this was great! :)

Thank you, this was great! :)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • 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>
  • Lines and paragraphs break automatically.

More information about formatting options

User login

Recent comments