Replacing blog.module with views

The following view definition uses view arguments to duplicate the functionality blog.module provides, with any node type. In addition, it allows urls like: www.example.com/blog/uid/2005/12 to generate filtered archive lists automatically.

The breadcrumbing looks a little odd, still allows nice backwards navigation.

<?php
  $view
= new stdClass();
 
$view->name = 'Blog';
 
$view->description = 'Weblog lijst';
 
$view->access = array ();
 
$view->page = TRUE;
 
$view->page_title = 'Blogs for %1 in %2 %3';
 
$view->page_header = '';
 
$view->page_header_format = '1';
 
$view->page_type = 'teaser';
 
$view->url = 'blog';
 
$view->use_pager = TRUE;
 
$view->nodes_per_page = '10';
 
$view->menu = TRUE;
 
$view->menu_title = 'blog';
 
$view->menu_tab = FALSE;
 
$view->menu_tab_default = FALSE;
 
$view->menu_weight = '';
 
$view->sort = array (
    array (
     
'tablename' => 'node',
     
'field' => 'sticky',
     
'sortorder' => 'ASC',
     
'options' => '',
    ),
    array (
     
'tablename' => 'node',
     
'field' => 'created',
     
'sortorder' => 'ASC',
     
'options' => '',
    ),
  );
 
$view->argument = array (
    array (
     
'type' => 'uid',
     
'argdefault' => '2',
     
'title' => 'Blogs',
     
'options' => '',
    ),
    array (
     
'type' => 'year',
     
'argdefault' => '2',
     
'title' => 'Blogs for %1',
     
'options' => '',
    ),
    array (
     
'type' => 'month',
     
'argdefault' => '2',
     
'title' => 'Blogs for %1 in %2',
     
'options' => '',
    ),
  );
 
$view->field = array (
  );
 
$view->filter = array (
    array (
     
'tablename' => 'node',
     
'field' => 'type',
     
'operator' => 'OR',
     
'options' => '',
     
'value' => array (
       
0 => 'blog',
      ),
    ),
    array (
     
'tablename' => 'node',
     
'field' => 'status',
     
'operator' => '=',
     
'options' => '',
     
'value' => '1',
    ),
    array (
     
'tablename' => 'node',
     
'field' => 'moderate',
     
'operator' => '=',
     
'options' => '',
     
'value' => '0',
    ),
  );
 
$view->requires = array(node);
 
$views[$view->name] = $view;
?>

 
 

Drupal is a registered trademark of Dries Buytaert.