Drupal view to create a list of category terms


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

Creates a category list showing the number of posts in each category similar to some blogging platforms. The view exposes a block and page.


Copy this code and paste it in your HTML
  1. $view = new stdClass();
  2. $view->name = 'Categories';
  3. $view->description = 'List of categories with number of articles posted in each category.';
  4. $view->access = array (
  5. 0 => '1',
  6. 1 => '2',
  7. );
  8. $view->view_args_php = '';
  9. $view->page = TRUE;
  10. $view->page_title = 'Browse Articles';
  11. $view->page_header = 'Browse articles by category.';
  12. $view->page_header_format = '1';
  13. $view->page_footer = '';
  14. $view->page_footer_format = '1';
  15. $view->page_empty = '';
  16. $view->page_empty_format = '1';
  17. $view->page_type = 'teaser';
  18. $view->url = 'articles';
  19. $view->use_pager = TRUE;
  20. $view->nodes_per_page = '100';
  21. $view->block = TRUE;
  22. $view->block_title = 'Categories';
  23. $view->block_header = '';
  24. $view->block_header_format = '1';
  25. $view->block_footer = '';
  26. $view->block_footer_format = '1';
  27. $view->block_empty = '';
  28. $view->block_empty_format = '1';
  29. $view->block_type = 'list';
  30. $view->nodes_per_block = '25';
  31. $view->block_more = TRUE;
  32. $view->block_use_page_header = FALSE;
  33. $view->block_use_page_footer = FALSE;
  34. $view->block_use_page_empty = FALSE;
  35. $view->sort = array (
  36. );
  37. $view->argument = array (
  38. 'type' => 'taxletter',
  39. 'argdefault' => '6',
  40. 'title' => '%1',
  41. 'options' => '',
  42. 'wildcard' => '',
  43. 'wildcard_substitution' => '',
  44. ),
  45. );
  46. $view->field = array (
  47. 'tablename' => 'node',
  48. 'field' => 'title',
  49. 'label' => '',
  50. 'handler' => 'views_handler_field_nodelink',
  51. 'sortable' => '1',
  52. 'options' => 'link',
  53. ),
  54. );
  55. $view->filter = array (
  56. 'tablename' => 'node',
  57. 'field' => 'status',
  58. 'operator' => '=',
  59. 'options' => '',
  60. 'value' => '1',
  61. ),
  62. );
  63. $view->exposed_filter = array (
  64. );
  65. $view->requires = array(node);
  66. $views[$view->name] = $view;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.