Drupal: View for blog content type


/ Published in: PHP
Save to your folder(s)

This will create a general site blog teaser list at /blog. It requires a cck type named blog. This view also generates an RSS feed for the blog. This is compatible with Views1 for Drupal 5.


Copy this code and paste it in your HTML
  1. $view = new stdClass();
  2. $view->name = 'blog';
  3. $view->description = 'Blog';
  4. $view->access = array (
  5. );
  6. $view->view_args_php = '';
  7. $view->page = TRUE;
  8. $view->page_title = 'Blog';
  9. $view->page_header = '';
  10. $view->page_header_format = '1';
  11. $view->page_footer = '';
  12. $view->page_footer_format = '1';
  13. $view->page_empty = 'No blog posts at this time. Please check back later.';
  14. $view->page_empty_format = '1';
  15. $view->page_type = 'teaser';
  16. $view->url = 'blog';
  17. $view->use_pager = TRUE;
  18. $view->nodes_per_page = '10';
  19. $view->block = TRUE;
  20. $view->block_title = 'Latest Blog Posts';
  21. $view->block_header = '';
  22. $view->block_header_format = '1';
  23. $view->block_footer = '';
  24. $view->block_footer_format = '1';
  25. $view->block_empty = '';
  26. $view->block_empty_format = '1';
  27. $view->block_type = 'list';
  28. $view->nodes_per_block = '6';
  29. $view->block_more = TRUE;
  30. $view->block_use_page_header = FALSE;
  31. $view->block_use_page_footer = FALSE;
  32. $view->block_use_page_empty = TRUE;
  33. $view->sort = array (
  34. 'tablename' => 'node',
  35. 'field' => 'created',
  36. 'sortorder' => 'DESC',
  37. 'options' => 'normal',
  38. ),
  39. );
  40. $view->argument = array (
  41. 'type' => 'rss_feed',
  42. 'argdefault' => '2',
  43. 'title' => '',
  44. 'options' => '',
  45. 'wildcard' => '',
  46. 'wildcard_substitution' => '',
  47. ),
  48. );
  49. $view->field = array (
  50. 'tablename' => 'node',
  51. 'field' => 'title',
  52. 'label' => '',
  53. 'handler' => 'views_handler_field_nodelink',
  54. 'options' => 'link',
  55. ),
  56. );
  57. $view->filter = array (
  58. 'tablename' => 'node',
  59. 'field' => 'status',
  60. 'operator' => '=',
  61. 'options' => '',
  62. 'value' => '1',
  63. ),
  64. 'tablename' => 'node',
  65. 'field' => 'type',
  66. 'operator' => 'OR',
  67. 'options' => '',
  68. 'value' => array (
  69. 0 => 'blog',
  70. ),
  71. ),
  72. );
  73. $view->exposed_filter = array (
  74. );
  75. $view->requires = array(node);
  76. $views[$view->name] = $view;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.