| Commit | Line | Data |
|---|---|---|
| 25b27fd0 EM |
1 | OVERVIEW |
| 2 | ||
| 3 | The views module provides a flexible method for Drupal administrators to control | |
| 4 | how lists of content are presented. Traditionally, Drupal has hard-coded most of | |
| 5 | this, particularly in how taxonomy and tracker lists are formatted. | |
| 6 | ||
| 7 | This tool is essentially a sort-of smart query builder that, given enough | |
| 8 | information, can build the proper query, execute it, and display the results. It | |
| 9 | has four modes, plus a special mode, and provides an impressive amount of | |
| 10 | functionality from these modes. | |
| 11 | ||
| c7184cd0 EM |
12 | 1) List View |
| 13 | The view can present the nodes as a simple list of fields, with each field | |
| 14 | encapsulated in a <div> tag, with an id based upon the field name. CSS can | |
| 15 | then be used to style the list. Which fields are presented and in what order | |
| 16 | is configurable within the view. | |
| 25b27fd0 | 17 | |
| c7184cd0 | 18 | 2) Table View |
| 25b27fd0 | 19 | It can provide information in a table. The user can pick and choose what |
| c7184cd0 EM |
20 | fields are presented, in what order they are presented, and how they are |
| 21 | presented. An example of this format is the classic tracker, as in | |
| 22 | http://drupal.org/tracker | |
| 25b27fd0 EM |
23 | |
| 24 | 3) Teaser List | |
| c7184cd0 EM |
25 | The module can provide node teasers, similar to the default front page |
| 26 | or taxonomy/term. | |
| 25b27fd0 EM |
27 | |
| 28 | 4) Full Nodes | |
| 29 | The module can provide lists of full nodes. I'm not sure how this would be | |
| c7184cd0 EM |
30 | useful. This could be useful if the list were limited to a single node. |
| 31 | ||
| 32 | 5) Random Node | |
| 33 | A view can be set to return a random node from a view, and display a teaser | |
| 34 | or a full node. | |
| 35 | ||
| 36 | 6) Summaries | |
| 37 | The last, special mode, exists only when the view expects arguments and does | |
| 38 | not get them. In this special 'summary' mode, it provides a list of what is | |
| 39 | available, with links to the more specific list. For example, many blogging | |
| 40 | sites offer archival content by month. If a view has the form of | |
| 41 | http://www.example.com/archive/YYYYMM, and the argument isn't specified, the | |
| 42 | summary would present all months available. | |
| 25b27fd0 | 43 | |
| 25b27fd0 EM |
44 | |
| 45 | FEATURES | |
| 46 | ||
| 47 | Views provides almost too many features in order to please the user. | |
| 48 | ||
| 49 | 1) Title | |
| 50 | The title of a view can be specified. | |
| 51 | ||
| 52 | 2) Header | |
| 53 | Each view can have an arbitrary amount of filtered text preceding it. This | |
| c7184cd0 EM |
54 | header can be a summary, instructions, or a description of what the user is |
| 55 | seeing. | |
| 25b27fd0 EM |
56 | |
| 57 | 3) Paging | |
| 58 | Views can be set to use the pager, and each view can have its own page size. | |
| c7184cd0 EM |
59 | Views can also opt not to use the pager, and limit the number of records |
| 60 | retrieved. | |
| 25b27fd0 EM |
61 | |
| 62 | 4) Sorting | |
| 63 | Views can be sorted by multiple fields, in either ascending or descending | |
| c7184cd0 | 64 | order. |
| 25b27fd0 EM |
65 | |
| 66 | 5) Filtering | |
| 67 | Views can be filtered to published status, front page status, node type, | |
| c7184cd0 EM |
68 | taxonomy type and vocabulary. In the future, views can be filtered to |
| 69 | arbitrary module fields. | |
| 25b27fd0 EM |
70 | |
| 71 | 6) Block or Page presentation | |
| 72 | Views can be presented either as blocks or pages; the same view can actually | |
| c7184cd0 | 73 | be used as both. Views can have menu entries. |
| 25b27fd0 | 74 | |
| c7184cd0 EM |
75 | 7) Arguments |
| 76 | Views can accept arbitrary arguments from the URL, and use these as filters. | |
| 25b27fd0 | 77 | Views can accept arguments such as User IDs, Node IDs, dates and taxonomy |
| c7184cd0 EM |
78 | terms. |
| 79 | ||
| 80 | 8) Themeing | |
| 81 | Each view can have its own theme, in the form of theme_view_VIEWNAME(), | |
| 82 | allowing theme designers and site administrators to pick and choose which | |
| 83 | views need additional formatting. The theme will receive the nodes already | |
| 84 | loaded from the query, along with any information needed for things such | |
| 85 | as table headers. | |
| 86 | ||
| 87 | 9) Module Developer API | |
| 88 | Views supports an API for module developers, allowing them to expose their | |
| 89 | tables and fields for viewing, sorting and filtering. | |
| 90 | ||
| 91 | 10) Default Views | |
| 92 | Both modules and the system itself can provide default views that can be | |
| 93 | utilized in various ways. These default views can be overriden by the | |
| 94 | admin and recustomized in any way desired. As this module sees wider | |
| 95 | use, the hope is that core modules will provide their node-list interfaces | |
| 96 | as views so that administrators can more easily customize how those views | |
| 97 | are presented. | |
| 25b27fd0 EM |
98 | |
| 99 | NOTES | |
| 100 | ||
| 101 | The module is implemented using only 4.6 features for now. I'd like to keep it | |
| 102 | this way until it's ready, and then jump it to 4.7, mostly because I don't have | |
| 103 | any 4.7 systems right now, and I don't want to take the time to upgrade or | |
| 104 | create one until there's a stable release. | |
| 105 | ||
| 106 | I probably wrote this thing a little too quickly. Some parts are better than | |
| 107 | others, and it's hard for me to tell which parts are which at this point. | |
| 108 | ||
| f8c376bf EM |
109 | database.inc has a minor bug that makes from_unixtime not work: |
| 110 | ||
| 111 | (line 246 in my version but it's kind of old). | |
| 112 | $query = preg_replace('|FROM[^[:upper:]/,]+|','\0 '. $join .' ', $query); | |
| 113 | should be | |
| 114 | $query = preg_replace('|FROM[^[:upper:]_/,]+|','\0 '. $join .' ', $query); | |
| 115 | ||
| 25b27fd0 | 116 | |
| a1345a71 | 117 | * Half-assed Changelog (mostly for schema): |
| b6e0975d EM |
118 | |
| 119 | 11/27/2005 added field 'handler' to view_tablefield | |
| a1345a71 | 120 | 11/28/2005 added fields 'sortable' and 'defaultsort' to view_tablefield |
| f8c376bf EM |
121 | 11/28/2005 changed view_argument type from int(2) to varchar(25) for greater flexibility |
| 122 | 11/30/2005 changed filter table and view table significantly. Probably sort table too. | |
| bdebd138 EM |
123 | 12/5/2005 Add options varchar(255) to both sort and filter tables. |
| 124 | 12/7/2005 Add menu_title to view_view and title to view_argument | |
| 42b26d51 | 125 | 12/8/2005 Added options varchar(255) to view_argument as well. |
| 627b83c0 EM |
126 | 12/10/2005 Added block_more int(1) to view_view |
| 127 | 12/21/2005 Renamed 'sql' to 'query' and 'countsql' to 'countquery' for consistency |