Now all modules are in core modules folder
17
modules/views/help/about.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
The views module allows administrators and site designers to create, manage, and display lists of content. Each list managed by the views module is known as a "view", and the output of a view is known as a "display". Displays are provided in either block or page form, and a single view may have multiple displays. Optional navigation aids, including a system path and menu item, can be set for each page-based display of a view. By default, views may be created that list content (a <em>Node</em> view type), content revisions (a <em>Node revisions</em> view type) or users (a <em>User</em> view type). A view may be restricted to members of specific user roles, and may be added, edited or deleted at the <a href="base_url:admin/build/views">views administration page</a>
|
||||
|
||||
The "building block" design of the views system provides power and flexibility, allowing parameters to be specified only when needed. While an advanced view may use all of available parameters to create complex and highly interactive applications, a simple content listing may specify only a few options. All views rely on a conceptual framework that includes:
|
||||
|
||||
<ul>
|
||||
<li><a href="topic:views/field">Fields</a>, or the individual pieces of data being displayed. Adding the fields <em>Node: Title</em>, <em>Node: Type</em>, and <em>Node: Post date</em> to a node view, for example, includes the title, content type and creation date in the displayed results </li>
|
||||
|
||||
<li><a href="topic:views/relationship">Relationships</a>, or information about how data elements relate to one another. If relationship data is available, like that provided by a CCK <em>nodereference</em> field, items from a related node may be included in the view </li>
|
||||
|
||||
<li><a href="topic:views/argument">Arguments</a>, or additional parameters that dynamically refine the view results, passed as part of the path. Adding an argument of <em>Node: Type</em> to a node view with a path of "content", for example, dynamically filters the displayed items by content type. In this example (shown with Clean URLs enabled), accessing the view through the path "<em>http://www.example.com/content/page</em>" displays all posts of the type "page", the path "<em>http://www.example.com/content/story</em>" displays all posts of the type "story", and "<em>http://www.example.com/content</em>" displays all posts regardless of type) </li>
|
||||
|
||||
<li><a href="topic:views/sort">Sort criteria</a>, which determine the order of items displayed in the view results. Adding the sort criteria <em>Node: Post date</em> (in descending order) to a node <em>view</em>, for example, sorts the displayed posts in descending order by creation date </li>
|
||||
|
||||
<li><a href="topic:views/filter">Filters</a>, which limit items displayed in the results. Adding the filter <em>Node: Published</em> (and setting it equal to "Published") to a node view, for example, prevents unpublished items from being displayed</li>
|
||||
|
||||
<li><a href="topic:views/display">Displays</a>, which control where the output will be seen. Every view has a default display, which doesn't actually display the view anywhere, but is used to hold the default settings for the view, and is used when the view is called programmatically if another display is not specified. Much more useful to users are the <a href="topic:views/display-page">page</a> display, which gives a view a path and allows it to be the primary content of a page, or the <a href="topic:views/display-block">block</a> display which allows it to appear as secondary content on other pages.</li>
|
||||
</ul>
|
23
modules/views/help/analyze-theme.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<p>You may use any of the following possible theme files to modify individual parts of your view. In total, there are four parts to theming a view.</p>
|
||||
<ul>
|
||||
<li> The <strong>display</strong> theme is usually views-view.tpl.php and it largely controls the decorations around a view; where the header, footer, pager, more link, feed icon, etc, will be placed. </li>
|
||||
|
||||
<li> The <strong>style</strong> will control how all of the results of the display are put together. It may be as simple as just displaying all of the rows, or it may be a complex table generator or something in between. </li>
|
||||
|
||||
<li> The <strong>row</strong> style controls each individual row; not all styles utilize the row style (notably the table), but most others do.
|
||||
|
||||
<li> Finally, <strong>field</strong> themes allow you to override the look and even the data of each individual field, if the style uses fields. The actual template the system will use should be hilighted in <strong>bold</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/style-breakdown-large.png"><img src="path:images/style-breakdown.png" /></a>
|
||||
<em>A breakdown of View output</em>
|
||||
</div>
|
||||
|
||||
<p>The link to the left of each type will give you information about the default template used for that type. You may cut and paste this and place it in your theme with the appropriate template, or you may copy the base file from the views/theme directory (or, if provided by a module, from the module's directory). <strong>It is important that you clear the theme registry cache every time you add a new template, or the new template will not be picked up.</strong></p>
|
||||
|
||||
<p><strong>Important note:</strong> You place your custom template files in your theme directory, <strong>not views/theme</strong>. This is always true of theming with Drupal.
|
||||
|
||||
<p>In addition to this tool, the very useful <a href="http://drupal.org/project/devel">devel</a> module contains a tool called the "Theme developer" which does a good job of visually showing you which areas of your site use which themes. Be careful with it, though, as the theme developer causes the Views edit page to break.</p>
|
||||
|
||||
<p>Also, this feature will only work properly with Drupal 6.3 and later; prior to Drupal 6.3 <a href="http://drupal.org/node/241570">this patch</a> will be required.</p>
|
105
modules/views/help/api-default-views.html
Normal file
|
@ -0,0 +1,105 @@
|
|||
Views can be stored in the database, which is typical of smaller sites and hobby sites. However, Views may also be stored directly in the code as "default" views, (which simply means they're available by default). Modules often come with views that are specific to the module data, but it's also possible -- and <b>highly</b> recommended -- that sites which have separate "development" and "production" sites export their views into default views in a site-specific module. This makes it very easy to transfer views from dev to production without making database changes.
|
||||
|
||||
<h3>Creating a module</h3>
|
||||
First, create a directory in <em>sites/all/modules</em> for your new module. Call it whatever you like, but for this example we will call it <em>mymodule</em>.
|
||||
|
||||
In this directory, create a <em>mymodule.module</em> file. It can be empty for now, but it should at least contain an opening PHP tag:
|
||||
<pre><?php
|
||||
// $Id $
|
||||
</pre>
|
||||
|
||||
It should not contain a closing ?> tag, as the closing ?> tag is not required and anything AFTER the closing tag, such as a space or a linefeed, will be displayed directly to the browser and can potentially cause problems.
|
||||
|
||||
The .module file will contain functions and drupal hooks. Hooks are specially named functions that Drupal will call in order to get your module's response at certain times while generating pages. The only function you will need for this exercise is the 'views_api' hook that tells Views that this module supports the Views API and what version:
|
||||
|
||||
<pre>function mymodule_views_api() {
|
||||
return array('api' => 2.0);
|
||||
}
|
||||
</pre>
|
||||
|
||||
For other uses you may well add additional functions.
|
||||
|
||||
Second, you need to create a <em>mymodule.info</em> file:
|
||||
|
||||
<pre>; $Id $
|
||||
name = My module
|
||||
description = My site specific module.
|
||||
core = 6.x
|
||||
</pre>
|
||||
|
||||
Once you have these two files set up, you should be able to activate your new module at the <em>Administer >> Site building >> Modules</em> page.
|
||||
<h3>Exporting your views</h3>
|
||||
|
||||
The easiest way to do this is to activate the 'views_export' module, and navigate to <em>Administer >> Views >> Tools >> Bulk export</em> Place a check next to each view that you want in your module, type the module name into the text field, and click export. This will create the entire <em>hook_views_default_views()</em> function for you.
|
||||
|
||||
You can also export individual views. If you do this, keep in mind that this export does not include the line that adds the exported $view into the larger $views array:
|
||||
|
||||
<pre>$views[$view->name] = $view</pre>
|
||||
|
||||
To place this into your <em>hook_views_default_views()</em> you will need to place that after the view, and make sure the function returns $views at the end.
|
||||
|
||||
<h3>Placing your exported views into your module</h3>
|
||||
Cut and paste the entire output of the bulk export tool into mymodule.views_default.inc -- and be sure to put a <?php at the top of the file so that the webserver knows that it's PHP code! Then visit the Views tools page and clear the Views cache. Your views should now be listed as <b>Overridden</b> on the view list page. If you <b>revert</b> these views, they will be removed from the database, but will remain in code.
|
||||
|
||||
<h3>Theming your views in your module</h3>
|
||||
You can theme these views in the module and not need to rely on the theme to do this at all; and in fact, the theme can continue to override these just like it ordinarily would, even if your module provides a theme. This is very useful for distributing a module where the view needs to look "just so."
|
||||
|
||||
To do this, you need to implement <em>hook_theme()</em> in your module:
|
||||
<pre>function mymodule_theme($existing) {
|
||||
return array(
|
||||
'views_view__viewname__displayid' => array (
|
||||
'arguments' => array('view' => NULL),
|
||||
'template' => 'views-view--viewname--displayid',
|
||||
'original hook' => 'views_view',
|
||||
'path' => drupal_get_path('module', 'mymodule'),
|
||||
),
|
||||
);
|
||||
}
|
||||
</pre>
|
||||
|
||||
There are a small number of gotchas in doing this that you must be aware of.
|
||||
|
||||
<ol>
|
||||
<li>When referring to a template filename, you always use dashes in the name. i.e, <em>views-view--viewname--displayid.tpl.php</em>. However, when referring to the hook or function names, you use underscores instead of dashes. i.e, <em>views_view</em> and <em>views_view__viewname__displayid</em></li>
|
||||
|
||||
<li>The 'arguments' change based upon which of the 3 types you're overriding. There's the 'display', the 'style' and the 'row' style. The above code is assuming the display, which is usually just <em>views_view</em>. Here are the possibilities:
|
||||
|
||||
<pre>display: array('view' => NULL),
|
||||
style: array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL),
|
||||
row style: array('view' => NULL, 'options' => NULL, 'row' => NULL),
|
||||
</pre>
|
||||
|
||||
Be sure to use the right arguments line or the theme system will not properly translate.
|
||||
</li>
|
||||
<li>The 'template' line should never include the extension, so drop the .tpl.php from it.</li>
|
||||
|
||||
<li>You need to make sure that the Views preprocess functions get registered. The 'original hook' line in the definition does that, but it can only do it if it comes after the Views registration, which actually happens very late in theme building. 99% of the time, your module will come before Views. You have two choices to deal with this:
|
||||
<ol>
|
||||
<li>Set your module's weight to 11 or higher in the database. Views' weight is 10. You can make this happen automatically when the module is first installed by creating a mymodule.install file and using this code:
|
||||
<pre>function mymodule_install() {
|
||||
db_query("UPDATE {system} SET weight = 11 WHERE name = 'mymodule'");
|
||||
}
|
||||
</pre>
|
||||
If you use this method, the <em>original hook</em> should be set to the name of the original template being used. i.e, if this is a variate of views-view-list.tpl.php, this should be 'views_view_list'.
|
||||
</li>
|
||||
<li>You can also just force it to list the preprocessors without actually having to detect them. This doesn't require modifying your module's weight, which is not always possible, you can insert this code into the array:
|
||||
<pre> 'preprocess functions' => array(
|
||||
'template_preprocess',
|
||||
'template_preprocess_views_view',
|
||||
'mymodule_preprocess_views_view__viewname_displayid',
|
||||
),
|
||||
</pre>
|
||||
|
||||
The first one is the global 'template_preprocess' function which all templates utilize. It does some basic things such as setting up $zebra and a few other items. See <a href="http://api.drupal.org/api/function/template_preprocess/6">api.drupal.org</a> for specifics.
|
||||
|
||||
The second one is the plugin specific preprocess. Like 'original hook' it should conform to the name used by the original template. i.e, if the original template was <em>views-view-list.tpl.php</em> then that preprocess function would be named <em>template_preprocess_views_view_list</em>.
|
||||
|
||||
The third one is your module's preprocess function, if it needs one. In general, you probably will not need one, and you should only attempt to use one if you are reasonably familiar with the concept of preprocess functions and Drupal's theme system in general. See Drupal's theme documentation for more information.
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
If you leave the path blank the template file will be searched for in "./" which is the Drupal install base path.
|
||||
</li>
|
||||
</ol>
|
||||
|
179
modules/views/help/api-example.html
Normal file
|
@ -0,0 +1,179 @@
|
|||
|
||||
For the new table defined by the Node example module to be understood by the views module you need to create a node_example.views.inc file that describes the table and its relationships to the rest of the database. In order for views to know that this file is to be loaded you need to implement hook_views_api. This is done by adding the following function into your node_example.module file
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
/**
|
||||
* Implementation of hook_views_api().
|
||||
*
|
||||
* This tells drupal that there is Views integration file named
|
||||
* module-name.views.inc
|
||||
*/
|
||||
function node_example_views_api() {
|
||||
// Note that you can include 'path' in this array so that your views.inc
|
||||
// file can be stored in a different location.
|
||||
return array(
|
||||
'api' => 2.0
|
||||
);
|
||||
}
|
||||
?>
|
||||
</pre>
|
||||
|
||||
Below is the contents of a simple node_example.views.inc file that allows you to create views that include the new color and quantity information.
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is used to tell the views module about the new node_example table.
|
||||
*
|
||||
* Database definition:
|
||||
* @code
|
||||
* CREATE TABLE node_example (
|
||||
* vid int(10) unsigned NOT NULL default '0',
|
||||
* nid int(10) unsigned NOT NULL default '0',
|
||||
* color varchar(255) NOT NULL default '',
|
||||
* quantity int(10) unsigned NOT NULL default '0',
|
||||
* PRIMARY KEY (vid, nid),
|
||||
* KEY `node_example_nid` (nid)
|
||||
* )
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
function node_example_views_data() {
|
||||
// Basic table information.
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// node_example table
|
||||
// New group within Views called 'Example'
|
||||
// The group will appear in the UI in the dropdown tha allows you
|
||||
// to narrow down which fields and filters are available.
|
||||
|
||||
$data = array();
|
||||
$data['node_example']['table']['group'] = t('Example');
|
||||
|
||||
// Let Views know that our example table joins to the 'node'
|
||||
// base table. This means it will be available when listing
|
||||
// nodes and automatically make its fields appear.
|
||||
//
|
||||
// We also show up for node revisions.
|
||||
$data['node_example']['table']['join'] = array(
|
||||
'node_revisions' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
// quantity
|
||||
$data['node_example']['quantity'] = array(
|
||||
'title' => t('Quantity'),
|
||||
'help' => t('Quantity of items.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
// Color
|
||||
$data['node_example']['color'] = array(
|
||||
'title' => t('Color'),
|
||||
'help' => t('Color of item.'),
|
||||
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
?>
|
||||
</pre>
|
||||
|
||||
Some notes on usage:
|
||||
|
||||
Within Views, click on the Add tab. You have a number of type options here. Normally you would select either 'Node' (if you only want to display information on current nodes) or 'Node revision' (if you want to display information on all revisions of the nodes)
|
||||
|
||||
With this configuration you always pull out of the database, data for every single node, whether or not it has color and quantity information. To display information on just those nodes that have color and quantity information you can use a filter so that only nodes which don't have a NULL color or a NULL quantity are displayed.
|
||||
|
||||
<h3>Type/relationship extension</h3>
|
||||
|
||||
When your tables have first class data, you will often need to have own View types and View relationships defined. With the current node_example table this isn't required although I try to justify it below on an efficiency basis. See [[http://groups.drupal.org/node/17236#comment-58980|this discussion]] as to why it isn't justified.
|
||||
|
||||
Pulling data out of the database for every node when you only want data for the new Example node type is inefficient. To reduce the initial data extraction to just that relating to the new Example nodes requires that you make the node_example table the base table. This can be done by adding the following code into the node_example.views.inc file just before the 'return $data;'
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
// **** Begin optional extra for type and relationships ****
|
||||
|
||||
// Use node_example as a new base table
|
||||
// by creating a new views type called 'Node example'
|
||||
// This allows it to be selected as the 'view type'
|
||||
// when you initially add a new view.
|
||||
$data['node_example']['table']['base'] = array(
|
||||
'field' => 'vid',
|
||||
'title' => t('Node example'),
|
||||
'help' => t("Node example type with color and quantity information."),
|
||||
'weight' => -9,
|
||||
);
|
||||
|
||||
// When using the new 'Node example' type you need to use relationships
|
||||
// to access fields in other tables.
|
||||
|
||||
// Relationship to the 'Node revision' table
|
||||
$data['node_example']['vid'] = array(
|
||||
'title' => t('Node revision'),
|
||||
'help' => t('The particular node revision the color and quantity is attached to'),
|
||||
'relationship' => array(
|
||||
'label' => t('Node revision'),
|
||||
'base' => 'node_revisions',
|
||||
'base field' => 'vid',
|
||||
// This allows us to not show this relationship if the base is already
|
||||
// node_revisions so users won't create circular relationships.
|
||||
'skip base' => array('node', 'node_revisions'),
|
||||
),
|
||||
);
|
||||
|
||||
// Relationship to the 'Node' table
|
||||
$data['node_example']['nid'] = array(
|
||||
'title' => t('Node'),
|
||||
'help' => t('The particular node the color and quantity is attached to'),
|
||||
'relationship' => array(
|
||||
'label' => t('Node'),
|
||||
'base' => 'node',
|
||||
'base field' => 'nid',
|
||||
// This allows us to not show this relationship if the base is already
|
||||
// node so users won't create circular relationships.
|
||||
'skip base' => array('node', 'node_revisions'),
|
||||
),
|
||||
);
|
||||
|
||||
// **** End optional extra for type and relationships ****
|
||||
|
||||
?>
|
||||
</pre>
|
||||
|
||||
The above code adds a new 'Node example' to the view types that can be selected within the Add tab window of views. Selecting this sets the node_example table to be the base table.
|
||||
|
||||
If you select 'Node example' as view type, when you initially go into the edit window of views you will find the only fields available are the color and quantity fields. To get fields from other tables you need to add a relationship. Relationships may be found at the top in the same column as the fields.
|
70
modules/views/help/api-handlers.html
Normal file
|
@ -0,0 +1,70 @@
|
|||
In Views, a handler is an object that is part of the view and is part of the query building flow.
|
||||
|
||||
Handlers are objects; much of the time, the base handlers will work, but often you'll need to override the handler for something. One typical handler override will be views_handler_filter_operator_in which allows you to have a filter select from a list of options; you'll need to override this to provide your list.
|
||||
|
||||
Handlers have two distint code flows; the UI flow and the view building flow.
|
||||
|
||||
For the query flow:
|
||||
|
||||
<dl>
|
||||
<dt>handler->construct()</dt>
|
||||
<dd>Create the initial handler; at this time it is not yet attached to a view. It is here that you can set basic defaults if needed, but there will be no knowledge of the environment yet.</dd>
|
||||
<dt>handler->set_definition()</dt>
|
||||
<dd>Set the data from hook_views_data() relevant to the handler.</dd>
|
||||
<dt>handler->init()</dt>
|
||||
<dd>Attach the handler to a view, and usually provides the options from the display.</dd>
|
||||
<dt>handler->pre_query()</dt>
|
||||
<dd>Run prior to the query() stage to do early processing.</dd>
|
||||
<dt>handler->query()</dt>
|
||||
<dd>Do the bulk of the work this handler needs to do to add itself to the query.</dd>
|
||||
</dl>
|
||||
|
||||
Fields, being the only handlers concerned with output, also have an extended piece of the flow:
|
||||
<dl>
|
||||
<dt>handler->pre_render()</dt>
|
||||
<dd>Called prior to the actual rendering, this allows handlers to query for extra data; the entire resultset is available here, and this is where items that have "multiple values" per record can do their extra query for all of the records available. There are several examples of this at work in the code.</dd>
|
||||
<dt>handler->render()</dt>
|
||||
<dd>This does the actual work of rendering the field.</dd>
|
||||
</dl>
|
||||
|
||||
Most handlers are just extensions of existing classes with a few tweaks that are specific to the field in question. For example:
|
||||
|
||||
<pre>
|
||||
/**
|
||||
* Filter by node type
|
||||
*/
|
||||
class views_handler_filter_node_type extends views_handler_filter_in_operator {
|
||||
function get_value_options() {
|
||||
if (!isset($this->value_options)) {
|
||||
$this->value_title = t('Node type');
|
||||
$types = node_get_types();
|
||||
foreach ($types as $type => $info) {
|
||||
$options[$type] = $info->name;
|
||||
}
|
||||
$this->value_options = $options;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<i>views_handler_filter_in_operator</i> provides a simple mechanism to set the list used and the rest of the handler is perfectly fine for this.
|
||||
|
||||
Handlers are stored in their own files; for these files to be loaded by Views on demand, they must first be registered. Since Views core handlers are also loaded this way, it's imperative that your module also implement this pattern in order to prevent code crashes when your handler's parent class is not yet available.
|
||||
|
||||
To register handlers, you must implement <strong>hook_views_handlers()</strong>. This hook returns an array with two keys; the first key is <em>info</em> which contains the modulename (which is only necessary if you're registering handlers on behalf of another module, such as what Views does) and <em>path</em>, which is the search path to find the files. This path is only necessary if your files will not be stored in the same directory as the .module file.
|
||||
|
||||
The other key is <em>handlers</em> which contains a full array of handlers and the information for each handler. The key to each handler array is the name of the handler class. It can contain:
|
||||
<dl>
|
||||
<dt><strong>parent</strong></dt>
|
||||
<dd>The class that this handler extends. This is important to make sure that the parent class is included before your handler class. Without this, you may cause people's sites to crash in a difficult to recover state. Be sure you get this right!</dd>
|
||||
<dt><strong>file</strong></dt>
|
||||
<dd>The filename the handler is in. By default, this will be classname.inc -- however, you can have multiple similar handlers together in one file. However, because there is only one parent, please be sure that the parentage on these handlers matches! Otherwise you will run into whitescreens as not all parents will be loaded.</dd>
|
||||
</dl>
|
||||
|
||||
You can see examples of this function in any of the various module.views.inc files in the views modules directory.
|
||||
|
||||
The best place to learn more about handlers and how they work is to explore <a href="http://views.doc.logrus.com">the views API site</a> and use existing handlers as a guide and a model. Understanding how views_handler and its child classes work is handy but you can do a lot just following these models. You can also explore the views module directory, particularly node.views.inc.
|
||||
|
||||
Please note that while all handler names in views are prefixed with views_, you should use your own module's name to prefix your handler names in order to ensure namespace safety. Note that the basic pattern for handler naming goes like this:
|
||||
|
||||
[module]_handler_[type]_[tablename]_[fieldname]. Sometimes table and fieldname are not appropriate, but something that resembles what the table/field would be can be used.
|
79
modules/views/help/api-plugins.html
Normal file
|
@ -0,0 +1,79 @@
|
|||
In Views, a plugin is a bit like a handler, but plugins are not directly responsible for building the query. Instead, they are objects that are used to display the view or make other modifications.
|
||||
|
||||
There are 6 types of plugins in Views:
|
||||
<dl>
|
||||
<dt>Display</dt>
|
||||
<dd>Display plugins are responsible for controlling <strong>where</strong> a view lives. Page and block are the most common displays, as well as the ubiquitous 'default' display which is likely what will be embedded.</dd>
|
||||
<dt>Style</dt>
|
||||
<dd>Style plugins control how a view is displayed. For the most part they are object wrappers around theme templates.
|
||||
<dt>Row style</dt>
|
||||
<dd>Row styles handle each individual record from a node.</dd>
|
||||
<dt>Argument default</dt>
|
||||
<dd>Argument default plugins allow pluggable ways of providing arguments for blocks. Views includes plugins to extract node and user IDs from the URL; additional plugins could be used for a wide variety of tasks.</dd>
|
||||
<dt>Argument validator</dt>
|
||||
<dd>Validator plugins can ensure arguments are valid, and even do transformations on the arguments.</dd>
|
||||
<dt>Access</dt>
|
||||
<dd>Access plugins are responsible for controlling access to the view.</dd>
|
||||
</dl>
|
||||
|
||||
Plugins are registered by implementing <strong>hook_views_plugins()</strong> in your modulename.views.inc file and returning an array of data.
|
||||
|
||||
The array will look something like this:
|
||||
<pre>
|
||||
return array(
|
||||
'display' => array(
|
||||
// ... list of display plugins,
|
||||
),
|
||||
'style' => array(
|
||||
// ... list of style plugins,
|
||||
),
|
||||
'row' => array(
|
||||
// ... list of row style plugins,
|
||||
),
|
||||
'argument default' => array(
|
||||
// ... list of argument default plugins,
|
||||
),
|
||||
'argument validator' => array(
|
||||
// ... list of argument validator plugins,
|
||||
),
|
||||
'access' => array(
|
||||
// ... list of access plugins,
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
Each plugin will be registered with an identifier for the plugin, plus a fairly lengthy list of items that can define how and where the plugin is used. Here is an example from Views core:
|
||||
|
||||
<pre>
|
||||
'node' => array(
|
||||
'title' => t('Node'),
|
||||
'help' => t('Display the node with standard node view.'),
|
||||
'handler' => 'views_plugin_row_node_view',
|
||||
'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
|
||||
'theme' => 'views_view_row_node',
|
||||
'base' => array('node'), // only works with 'node' as base.
|
||||
'uses options' => TRUE,
|
||||
'type' => 'normal',
|
||||
),
|
||||
</pre>
|
||||
|
||||
Of particular interest is the <em>path</em> directive, which works a little differently from handler registration; each plugin must define its own path, rather than relying on a global info for the paths. Also, there is an optional <em>parent</em> directive which is automatically filled in to be the base parent for the plugin type. Usually this is enough, but if your plugin derives from something other than the base, it must be filled in. For example:
|
||||
|
||||
<pre>
|
||||
'feed' => array(
|
||||
'title' => t('Feed'),
|
||||
'help' => t('Display the view as a feed, such as an RSS feed.'),
|
||||
'handler' => 'views_plugin_display_feed',
|
||||
'parent' => 'page', // so it knows to load the page plugin .inc file
|
||||
'uses hook menu' => TRUE,
|
||||
'use ajax' => FALSE,
|
||||
'use pager' => FALSE,
|
||||
'accept attachments' => FALSE,
|
||||
'admin' => t('Feed'),
|
||||
'help topic' => 'display-feed',
|
||||
),
|
||||
</pre>
|
||||
|
||||
Note that unlike handler registration, where parentage is referred to by object name, with plugins it is referred to by the unique plugin identifier. Please be sure to prefix your plugin identifiers with your module name to ensure namespace safety; after all, two different modules could try to implement the 'grid2' plugin, and that would cause one plugin to completely fail.
|
||||
|
||||
...TODO: Finish this document....
|
236
modules/views/help/api-tables.html
Normal file
|
@ -0,0 +1,236 @@
|
|||
Tables are described to Views via hook_views_data(), which returns an array of table information, keyed by the name of the table. For example, if your module is describing three tables, 'foo', 'bar' and 'baz', your array will look like this:
|
||||
<pre>$data = array(
|
||||
'foo' => array(
|
||||
// ...info here...
|
||||
),
|
||||
'bar' => array(
|
||||
// ...info here...
|
||||
),
|
||||
'baz' => array(
|
||||
// ...info here...
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
The key should be the actual database name of the table (not including prefix), but it can be an alias as long as the join information (explained later) contains the real name of the table.
|
||||
|
||||
Each item in the array should be a field in the table, with the exception of a special information section called 'table'. Example:
|
||||
|
||||
<pre>$data['foo'] = array(
|
||||
'table' => array(
|
||||
// ... info about the table, described later ...
|
||||
),
|
||||
'bar' => array(
|
||||
// ... info about the field named 'bar', i.e, foo.bar,
|
||||
),
|
||||
'baz' => array(
|
||||
// ... info about the field named 'baz', i.e, foo.baz,
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
Once you get down to an array that contains actual data, that piece of the array will often be referred to as the definition.
|
||||
|
||||
<h2>The 'table' section</h2>
|
||||
Each table should have a 'table' section in it, which is used to set default information for the table, such as the group, as well as the very important joins and whether or not this is a base table.
|
||||
|
||||
First, there are several items that are actually for fields but can be placed here so that all fields within the table inherit them:
|
||||
<dl>
|
||||
<dt>group</dt>
|
||||
<dd>The name of the group this item will be with. In the UI, this is displayed as Group: Title. For example, "Node: Node ID", "Taxonomy: Term description", etc. It is important to be consistent with groups, because the UI sorts by group, and allows filtering by group to find fields as well.</dd>
|
||||
<dt>title</dt>
|
||||
<dd>The actual name of the field; it should be concise and descriptive.</dd>
|
||||
<dt>help</dt>
|
||||
<dd>A longer description to help describe what the field is or does. It should try to be only a line or two so as not to clutter the UI.</dd>
|
||||
</dl>
|
||||
|
||||
In general, having 'title' and 'help' at the table level doesn't make a lot of sense, but usually every item in a table is in the same group. Thus it is very common to define the 'group':
|
||||
|
||||
<pre>
|
||||
$data['foo']['table']['group'] = t('Foo');
|
||||
</pre>
|
||||
|
||||
The other items in the 'table' section are described in the following sections.
|
||||
|
||||
<h3>'base': Base table</h3>
|
||||
If your table is a base table -- meaning it can be the primary, central table for a View to use, you can declare it to be a base table. This primarily provides UI information so that it can be selected.
|
||||
For example:
|
||||
<pre>
|
||||
// Advertise this table as a possible base table
|
||||
$data['node']['table']['base'] = array(
|
||||
'field' => 'nid',
|
||||
'title' => t('Node'),
|
||||
'help' => t("Nodes are a Drupal site's primary content."),
|
||||
'weight' => -10,
|
||||
);
|
||||
</pre>
|
||||
|
||||
The following items are available in the base section :
|
||||
<dl>
|
||||
<dt>field</dt>
|
||||
<dd>The primary key field for this table. For Views to treat any table as a base table, it <b>must</b> have a primary field. For node this is the 'nid', for users this is the 'uid', etc. <strong>Without a single primary key field (i.e. not a composite key), Views will not be able to utilize the table as a base table.</strong> If your table does not have a primary key field, it is not too difficult to just add a serial field to it, usually.</dd>
|
||||
<dt>title</dt>
|
||||
<dd>The title of this table in the UI. It should be singular and describe the object that this table contains from the perspective of the user.</dd>
|
||||
<dt>help</dt>
|
||||
<dd>A short piece of text to describe what object this table contains.</dd>
|
||||
<dt>database</dt>
|
||||
<dd>If this table is held in a different database from your Drupal database, specify it as a string in the exact same format as the settings.php file. This is a special purpose variable that will probably be only used in site specific code, and <b>it must be the same database type as your Drupal database</b>. Also, don't try to join it to any table that isn't in the same database. That'll just create all kinds of silly errors. For example:
|
||||
<pre>
|
||||
// In settings.php for your site
|
||||
// Your drupal (site) database needs to be called 'default'
|
||||
$db_url['default'] = 'mysqli://user:pass@host/drupal_db';
|
||||
$db_url['budget'] = 'mysqli://user:pass@host/other_db';
|
||||
</pre>
|
||||
Then when you are describing the external database in your base table you would write something like this:
|
||||
<pre>
|
||||
$data[$table]['table']['base'] = array(
|
||||
'field' => 'Primary key',
|
||||
'title' => t('Field name'),
|
||||
'help' => t('Field description'),
|
||||
'database' => 'budget',
|
||||
'weight' => -10,
|
||||
);
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h3>'join': Linking your table to existing base tables</h3>
|
||||
For Views to use your table, it has to either be a base table, or know how to link to an existing base table. Or sometimes both. Views uses this information to create a path to the base table; when the table is added to the query, Views will walk along this path, adding all tables required into the query.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/node-term_node-term_data-large.png"><img src="path:images/node-term_node-term_data.png" /></a>
|
||||
<em>How term_data joins to node</em>
|
||||
</div>
|
||||
|
||||
In the above example, to use these with 'node' as the base table, both 'term_data' and 'term_node' need to be defined, and they each need a join handler for node:
|
||||
|
||||
<pre>
|
||||
$data['term_data']['table']['join']['node'] = array(
|
||||
'left_table' => 'term_node',
|
||||
'left_field' => 'tid',
|
||||
'field' => 'tid',
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above can be read as "In order to join to the node table, the term_data table must first link to the term_node table, and they join on the 'tid' field.". When adding this table to the query for a node view, Views will look at this and then look for the term_node table.
|
||||
|
||||
<pre>
|
||||
$data['term_node']['table']['join']['node'] = array(
|
||||
'left_field' => 'nid',
|
||||
'field' => 'nid',
|
||||
);
|
||||
</pre>
|
||||
|
||||
Above, the fact that 'left_table' is left out lets us know that term_node links directly to the node table, using the 'nid' field on both sides of the join.
|
||||
|
||||
Quite a few more fields are available in this definition:
|
||||
<dl>
|
||||
<dt>handler</dt>
|
||||
<dd>The name of the handler object to use. Defaults to 'views_join'. You may create custom join handlers that may or may not use any of the data below, as they see fit.</dd>
|
||||
<dt>table</dt>
|
||||
<dd>Table to join. This is optional, and should only be used if the table being referenced is an alias.</dd>
|
||||
<dt>field</dt>
|
||||
<dd>Field to join on. This is required.</dd>
|
||||
<dt>left_table</dt>
|
||||
<dd>The next step toward the final destination. If this is the final destination it may be omitted.</dd>
|
||||
<dt>left_field</dt>
|
||||
<dd>The field to join to on the left side. This is required.</dd>
|
||||
<dt>type</dt>
|
||||
<dd>Either LEFT (default) or INNER.</dd>
|
||||
<dt>extra</dt>
|
||||
<dd>Either a string that's directly added, or an array of items. Each item is, itself, an array:
|
||||
<dl>
|
||||
<dt>field</dt>
|
||||
<dd>Field or formula</dd>
|
||||
<dt>operator</dt>
|
||||
<dd>Similar to filters, this is the operator, such as >, <, =, etc. Defaults to = or IN.</dd>
|
||||
<dt>value</dt>
|
||||
<dd>Must be set. If an array, operator will be defaulted to IN.</dd>
|
||||
<dt>numeric</dt>
|
||||
<dd>If true, the value will not be surrounded in quotes, and %d will be used for its placeholder.</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>extra type</dt>
|
||||
<dd> How all the extras will be combined. Either AND or OR. Defaults to AND.</dd>
|
||||
</dl>
|
||||
|
||||
<h2>Describing fields on tables</h2>
|
||||
Aside from the special table tag, each table can also have an unlimited number of field designations; these correspond roughly to fields on the table, though it is very common to use non-fields to display data that isn't directly in a field, such as data arrived from formulae, or special links related to the object the table is part of.
|
||||
|
||||
Each field is described in the view data with an array, keyed to the database name of the field. This array may contain some information fields, plus an entry in each of the five types of items Views has per field: argument, field, filter, relationship, sort. For example:
|
||||
|
||||
<pre>
|
||||
$data['node']['nid'] = array(
|
||||
'title' => t('Nid'),
|
||||
'help' => t('The node ID of the node.'), // The help that appears on the UI,
|
||||
// Information for displaying the nid
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_node',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
// Information for accepting a nid as an argument
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_node_nid',
|
||||
'name field' => 'title', // the field to display in the summary.
|
||||
'numeric' => TRUE,
|
||||
'validate type' => 'nid',
|
||||
),
|
||||
// Information for accepting a nid as a filter
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
// Information for sorting on a nid.
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above example describes the 'nid' field on the 'node' table, providing 4 of the 5 handlers. Note that while field is normally expected to be the database name of the field, it doesn't have to be; you can use an alias (which is how you get multiple handlers per field) or something completely made up for items that aren't tied to the database. For example:
|
||||
|
||||
<pre>
|
||||
$data['node']['edit_node'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Edit link'),
|
||||
'help' => t('Provide a simple link to edit the node.'),
|
||||
'handler' => 'views_handler_field_node_link_edit',
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above handler definition an edit link to a node, but this isn't a field in and of itself. For aliased fields, here is another example:
|
||||
|
||||
<pre>
|
||||
$data['users']['uid_current'] = array(
|
||||
'real field' => 'uid',
|
||||
'title' => t('Current'),
|
||||
'help' => t('Filter the view to the currently logged in user.'),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_user_current',
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above definition provides an alternate filter handler on the uid field for the current user.
|
||||
|
||||
The following items are allowed in the field definition:
|
||||
|
||||
<dl>
|
||||
<dt>group, title, help</dt>
|
||||
<dd>As above, these fields are for the UI. If placed here, any of these fields will override a setting on the base table.</dd>
|
||||
<dt>real field</dt>
|
||||
<dd>If this field is an alias, the "real field" may be placed here, and the handler will never know the difference.</dd>
|
||||
|
||||
<dt>field</dt>
|
||||
<dd>A handler definition for the "Field" section, which is a field that may be displayed in a view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_field'.</dd>
|
||||
<dt>filter</dt>
|
||||
<dd>A handler definition for the "Filters" section, which will be used to apply WHERE clauses to the view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_filter'.</dd>
|
||||
<dt>sort</dt>
|
||||
<dd>A handler definition for the "Sort criteria" section, which will be used to add an ORDER BY clause to the view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_sort'.</dd>
|
||||
<dt>relationship</dt>
|
||||
<dd>A handler definition for the "Field" section, which is a way to bring in new or alternative base tables in the view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_relationship'. The basic relationship handler requires 'base' and 'base field' to be set; 'base' and 'base field' represent the "right" half of the join that will use this field as the left side.</dd>
|
||||
<dt>argument</dt>
|
||||
<dd>A handler definition for the "Field" section, which is method of accepting user input from the URL or some other source. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_argument'.</dd>
|
||||
</dl>
|
||||
|
||||
For more information about what handlers need/use what data, visit <a href="http://views.doc.logrus.com">the Views API site</a> and check out the available handlers.
|
22
modules/views/help/api.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
Views allows modules to describe their tables relationships to each other, as well as fields, filters, sort criteria and arguments via <strong>hook_views_data()</strong>. Whenever Views deems it necessary, this hook is called, the data aggregated together and cached. <strong>hook_views_data_alter()</strong> may also be used to modify existing data, changing other module's handlers or adding handlers to other module's tables.
|
||||
|
||||
Views also allows modules to create new display types, style types, row styles, argument default handlers and argument validators via <strong>hook_views_handlers()</strong> and <strong>hook_views_plugins()</strong>.
|
||||
|
||||
These hooks are kept in a file named MODULENAME.views.inc. This file is automatically included upon need, so there is no need to try and include this in hook_init or any other method of including .inc files. This file should store hook_views_data, hook_views_data_alter(), hook_views_plugins(), hook_views_handlers(), as well as any other hooks and subsidiary data that will only be used by your module when Views is active. All handlers and plugins provided by your module should be in separate .inc files.
|
||||
|
||||
There are two similar files, MODULENAME.views_default.inc and MODULENAME.views_convert.inc which contain default views and views 1 to views 2 convert helpers, respectively.
|
||||
|
||||
<h3>hook_views_api()</h3>
|
||||
<strong>In order for your files to be included, your module must first implement hook_views_api()</strong> in the main .module file. This module should return array of information. The following items may be returned:
|
||||
|
||||
<dl>
|
||||
<dt><strong>api</strong></dt>
|
||||
<dd>This must appear; it should be the oldest API version that your module can work with. If Views is currently running an older version of the API, it will ignore your module's views integration. This is a good thing, as it will prevent code crashes, at the expense of your module's functionality disappearing.
|
||||
<br />
|
||||
You may find the current Views API version by calling <strong>views_api_version()</strong> which is implemented at the top of views.module. This version numbering starts at 2.0. Every time changes are made to the Views handlers and plugins or other aspects of the Views API, the number will tick up (by either .001, .01 .1 or 1 depending upon how major the changes are). Note that <strong>views_api_version()</strong> was introduced in Views 2.0-rc2 and may not exist prior to that version. You may use function_exists() to test to see if this function is there.
|
||||
<br />
|
||||
Often these versions are basically compatible with each other and Views won't care if your module implements 2.000, 2.001, 2.002, etc. Your module can request that it won't work with any version older than a given version, however. Views will determine, itself, if a newer version will work.
|
||||
</dd>
|
||||
<dt><strong>path</strong></dt>
|
||||
<dd>If your *.views*.inc files are not in the same directory as the .module file, then return the full path here. You should probably use something like drupal_get_path('module', 'yourmodulename') . '/includepath'.</dd>
|
||||
</dl>
|
57
modules/views/help/argument.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
Arguments are input. While they often come from the URL, <strong>they don't always</strong> so please don't be shocked when they don't. Each display type may have its own source for arguments. Block displays have no source of arguments at all; they cannot pull arguments from the URL, and often require use of the default argument PHP code in order to get arguments. The argument default plugins can be used to get arguments into a block view. See "Provide default", below.
|
||||
|
||||
In general, arguments are used to filter the view, and in that sense they have a very close relationship to filters, but that isn't necessarily true for every argument. Arguments can be used for any purpose, really; the extent of what the argument does is up to the developer of the argument, but the arguments that come with Views are almost entirely filters.
|
||||
|
||||
A typical use of an argument might be to reduce a view to a single node, a single user, or nodes with a given taxonomy term.
|
||||
|
||||
<h3>Action to take if argument is not present</h3>
|
||||
<dl>
|
||||
<dt>Ignore</dt>
|
||||
<dd>The argument is removed from the view as though it weren't there and all results will be displayed.</dd>
|
||||
|
||||
<dt>Hide view / Page not found</dt>
|
||||
<dd>The view will remove itself entirely if the argument is not present; for a block this means it simply won't appear. For page views the View will return a 404 and present a "Page not found" error. </dd>
|
||||
|
||||
<dt>Display empty text</dt>
|
||||
<dd>The value of the <a href=topic:views/empty-text>empty text</a> will be displayed.</dd>
|
||||
|
||||
<dt>Summary</dt>
|
||||
<dd>The view will attempt to display a summary of arguments available, based upon the view, and provide links to the view with those arguments. Summaries have their own style handlers as well as options. The default summary style simply displays a list of arguments with a count of entries found per argument. This special mode is a very powerful part of Views.</dd>
|
||||
|
||||
<dt>Provide default</dt>
|
||||
<dd>If no argument is given, a default argument can be selected. The method of choosing the default argument is selectable and pluggable.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Wildcards</h3>
|
||||
All arguments have a 'wildcard', which is an argument that means to use all values. In practice, it is the same as 'Ignore' above, where the argument is simply removed and the view is created without the argument. The wildcard title is used in titles and breadcrumb trails.
|
||||
<h3>Default arguments</h3>
|
||||
Default argument selection is available <strong>only if the action to take is "Provide default"</strong>. When that is selected, a new fieldset will appear letting you choose what the default argument will be. Views provides the following default selectors by default (but other modules may add more):
|
||||
<dl>
|
||||
<dt>Fixed entry </dt>
|
||||
<dd>You may directly enter what the argument will be. This is not a variable, it will always be the same argument. </dd>
|
||||
<dt>Node ID from URL</dt>
|
||||
<dd>This will attempt to find a Node ID from the URL, and is primarily useful for the Node: ID argument (though other arguments that use Node IDs, such as the CCK Node Reference argument, will find it useful too). For example, when visiting the path 'node/1' or 'node/1/edit' it will know that the '1' in that path is a node ID and use it.</dd>
|
||||
<dt>User ID from URL</dt>
|
||||
<dd>Like Node ID from URL, this will attempt to find a user ID from the path. It also includes an option to look for a node and use the node author as the user ID.</dd>
|
||||
<dt>User ID from logged in user</dt>
|
||||
<dd>You can use this to easily default a menu item to the logged in user. For example, if you created the path 'blogs' and gave it a User: ID argument with this default, 'blogs' would go to the user's own blogs, and blogs/1 would go to User ID 1's blogs.</dd>
|
||||
</dl>
|
||||
|
||||
Please bear in mind that the selection of default argument happens only if an argument is not provided. If using a display that has no argument source, such as a block, this will always be used. However, if using a display that reads arguments from the URL, this will happen only if the URL did not contain an argument.
|
||||
<h3>Argument validation</h3>
|
||||
Arguments can also have validators, which are pluggable systems used to ensure that arguments fit within certain parameters. When a validator is chosen, it may provide some settings for the validator, including the action to take if an argument is presented, but it fails to validate. These actions are generally the same as the default actions above, excluding the ability to provide another default.
|
||||
|
||||
If a view provides a menu option, such as a tab, if the argument does not validate the tab will not appear.
|
||||
|
||||
This sytem can have other validators plugged in; by default, Views provides:
|
||||
<dl>
|
||||
<dt>Basic validation</dt>
|
||||
<dd>Ensures that the argument is present. A PHP NULL value (from eg. PHP default argument code) will invalidate.</dd>
|
||||
<dt>Node</dt>
|
||||
<dd>Ensure that the argument is a valid Node ID. You may select which types of node the validator will accept.</dd>
|
||||
<dt>Taxonomy term</dt>
|
||||
<dd>Ensure that the argument is a valid taxonomy term. This includes options to limit to specific vocabularies and can transform the argument to the right type depending upon the actual argument. Set the Argument Type option to the actual type of data that the argument being used is expecting.</dd>
|
||||
<dt>PHP Code</dt>
|
||||
<dd>You may enter arbitrary PHP code, similar to the php block visibility code, to determine if the argument is valid or not.</dd>
|
||||
|
||||
</dl>
|
1
modules/views/help/display-attachment.html
Normal file
|
@ -0,0 +1 @@
|
|||
Attachment displays are 'attached' to another display in the same view. When the display is visited, the attached display will also be rendered and may be placed before, after or both before and after the original display. Attachment displays are often useful for displaying an argument summary view along with a page display that accepts arguments. This can be used to provide a kind of glossary.
|
10
modules/views/help/display-block.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
Block displays will show up on your blocks administration page. Once a block display is created and saved, it can be enabled and positioned in your theme by visiting <strong>administer >> site building >> blocks</strong> and selecting it from the list.
|
||||
|
||||
Blocks <strong>do not</strong> accept arguments from any source; the only way to get arguments to a block is to provide defaults to it, possibly via the PHP Code default setting.
|
||||
|
||||
<ul>
|
||||
<li>Edit the argument in question; you may want to override this argument if you have multiple displays using it.</li>
|
||||
<li>Change the "Action to take if argument is not present" to "Provide default argument". This will bring up a new box called "Provide default argument options".</li>
|
||||
<li>The most common default argument type used for blocks is Node from URL, where it attempts to determine if the URL refers to a node, for example if visiting 'node/1' or 'node/1/edit'. User ID from URL is also very common.</li>
|
||||
<li>If you change the default argument type to 'PHP Code' (note: You must have permission to use PHP code on your site) you can enter PHP to define the argument needed. Simply return the argument.</li>
|
||||
</ul>
|
4
modules/views/help/display-default.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
The default display is primarily a display to store settings, and isn't actually used anywhere within the Views system. It is possible for external programs to use the default display, but if they do they will (hopefully) tell you which display they will be working with. The default display is also a convenient display to use to embed into your site using PHP snippets; this is useful, for example, in node content, but this is something that should generally only be done by administrators.
|
||||
|
||||
In general, you probably want to add either a <a href="topic:views/display-page">page display</a> or a <a href="topic:views/display-block">block display</a>.
|
||||
|
1
modules/views/help/display-feed.html
Normal file
|
@ -0,0 +1 @@
|
|||
A feed display allows you to attach an RSS feed to a view.
|
5
modules/views/help/display-page.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
Page displays have a <a href="topic:views/path">path</a> and an optional <a href="topic:views/menu">menu</a> component. Page displays will be the primary content for the page, meaning they will be displayed in the main content area when you visit the URL that corresponds to the path.
|
||||
|
||||
Page displays take their arguments from the URL. You can embed arguments into the URL using %; in previous versions of Views, this was '$arg'. For example, 'node/%/foo' will accept URLs such as 'node/1/foo'.
|
||||
|
||||
Please remember that using a % placeholder makes the argument required. If you wish to have an optional argument, simply omit the % from the path. I.e. using "page/%" as the path requires an argument and visiting 'http://www.example.com/page' will not trigger the view.
|
7
modules/views/help/display.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
Displays tell Views where the output should go. By adding a display to a View, you can have your view appear as a page, or as a block, or even as an attachment to a different display on the view.
|
||||
|
||||
Each display can have its own settings, but when it's created, a display will take all of its <em>basic settings</em> from the <strong>default display</strong> which all Views must have. For most settings, there is an <strong>override</strong> button that will override that single setting for the current display. Overridden settings will have a mark in the summary for that display. All 'default display settings' are shown in the other displays '<i>italic</i>'. When you override a setting, than it is shown 'normal'.
|
||||
|
||||
Please keep in mind that when you are editing a setting on a display that is not overridden, then by default you are editing that for all displays.
|
||||
|
||||
For <strong>fields</strong>, <strong>arguments</strong>, <strong>sorts</strong>, <strong>filters</strong> and <strong>relationships</strong>, you can only override <em>all</em> of them or none of them. To do this, click on the header for the filters or the rearrange button. Once you override, the display will then have its own copies of the fields/filters/etc and changes to the defaults will not be reflected on your display.
|
24
modules/views/help/embed.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
You can easily embed the results of a view into other parts of your site;
|
||||
either with code as a module, or in nodes or blocks as snippets. The
|
||||
easiest way is to use the function <strong>views_embed_view()</strong>:
|
||||
|
||||
<code>/**
|
||||
* Embed a view using a PHP snippet.
|
||||
*
|
||||
* This function is meant to be called from PHP snippets, should one wish to
|
||||
* embed a view in a node or something. It's meant to provide the simplest
|
||||
* solution and doesn't really offer a lot of options, but breaking the function
|
||||
* apart is pretty easy, and this provides a worthwhile guide to doing so.
|
||||
*
|
||||
* @param $name
|
||||
* The name of the view to embed.
|
||||
* @param $display_id
|
||||
* The display id to embed. If unsure, use 'default', as it will always be
|
||||
* valid. But things like 'page' or 'block' should work here.
|
||||
* @param ...
|
||||
* Any additional parameters will be passed as arguments.
|
||||
*/
|
||||
function views_embed_view($name, $display_id = 'default') {
|
||||
</code>
|
||||
|
||||
To figure out the id of a display, hover your mouse over the tab to select that display. Everything after the '#views-tab-' is the id of that display. This ID is guaranteed never to change unless you delete the display and create a new one.
|
77
modules/views/help/example-author-block.html
Normal file
|
@ -0,0 +1,77 @@
|
|||
<p>In this example you will create a context-sensitive block that shows the titles of recent blog entries by an author when viewing one of their posts. This will demonstrate using Views <em>arguments</em> to dynamically filter a view's contents at display time.</p>
|
||||
|
||||
<p>Before working through this example, enable the <strong>Blog</strong> module and populate some entries from a few different users.</p>
|
||||
|
||||
<h3>Creating the View</h3>
|
||||
<p>The first step is creating a view for our recent blog entries block. Because the block will show the titles of blog entries, this view is considered a "Node" type. Go to <a target="_blank" href="/admin/build/views/add">add new view</a>, enter the following properties, and click <strong>Next</strong>:</p>
|
||||
|
||||
<dl>
|
||||
<dt>View name</dt>
|
||||
<dd>recent_blog_entries</dd>
|
||||
<dt>View description</dt>
|
||||
<dd>List of recent blog entries for a given author.</dd>
|
||||
<dt>View tag</dt>
|
||||
<dd>blog</dd>
|
||||
<dt>View type</dt>
|
||||
<dd>Node</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Generating a list of blog entries</h3>
|
||||
<p>It will be much easier to see the view progress if we can see it doing something. In this section, we will create a basic view displaying blog entry titles.</p>
|
||||
|
||||
<ol>
|
||||
<li>In the third column, locate the <strong>Fields</strong> area. Generally speaking, fields are the pieces of information that you want to display in the view (in this case, node title). Click the <strong>+</strong> icon to add a field.</li>
|
||||
<li>Scroll down to <strong>Defaults: Add fields</strong>, below the settings table. A large selection of fields will be available.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu, select <em>Node</em>. This will limit the list to only the default fields exposed by Node module.</li>
|
||||
<li>Scroll down the list, select the <em>Node: Title</em> field, and click <strong>Add</strong>.</li>
|
||||
<li>You will now be presented with settings for the <em>Node: Title</em> field. Delete the label from the <strong>Label</strong> field, so that each individual node title is not prefixed with the word "Title." Additionally, check the <em>Link this field to its node</em> box so that visitors who see an interesting title can click directly on it to read the blog entry to which it belongs.</li>
|
||||
<li>When finished, click <strong>Update</strong>. If you scroll down to the <strong>Live Preview</strong> section, you should now see a list of several node titles; however both blog entries and other node types will be in the list. Let's fix that.</li>
|
||||
<li>In the fourth column, locate the <strong>Filters</strong> area. Filters limit the results displayed in the view, and we can use this to our advantage here by showing node titles only from blog entries and not every type of node. Click the <strong>+</strong> icon to add a filter.</li>
|
||||
<li>As before, scroll down to the <strong>Defaults: Add filters</strong> section, select <em>Node</em> from the <strong>Groups</strong> select box to limit the list of options to only those exposed by Node module.</li>
|
||||
<li>Scroll down and select the <em>Node: Type</em> field and click <strong>Add</strong>. In the settings page that appears, leave <strong>Operator</strong> as <em>Is one of</em> and select <em>Blog entry</em> under <strong>Node type</strong>. Click <strong>Update</strong> when finished.</li>
|
||||
<li>Now, by scrolling down to <strong>Live preview</strong>, you'll see that the list only shows blog entries.</li>
|
||||
</ol>
|
||||
|
||||
<h3>Adding context with arguments</h3>
|
||||
<p>While filters are very useful for limiting the results of a view when the condition is always consistent (for example, a view of blog entry nodes should <em>always</em> be filtered by the blog entry type), something filters can't do is smart decision-making based on the page context. In our case, we want the view to display a different list of blog entries when looking at a post by user 'admin' than we do when looking at a post by user 'member', and filters won't be able to help.</p>
|
||||
|
||||
<p>Luckily, there's another way to filter a view's content: <em>arguments</em>. Through arguments, Views are able to obtain additional context (typically via dynamic URLs with IDs in them) and can take this context into consideration when displaying the view.</p>
|
||||
|
||||
<p>Let's walk through adding and configuring an argument to our view so that we can change its contents based on post author.</p>
|
||||
|
||||
<ol>
|
||||
<li>In the third column, locate the <strong>Arguments</strong> area. Click the <strong>+</strong> icon to add an argument.</li>
|
||||
<li>Because we are basing the view around content <em>authors</em>, this time under <strong>Groups</strong> select <em>User</em>. Check <em>User: Uid</em> and click <strong>Add</strong>.</li>
|
||||
<li>The <strong>Defaults: Configure Argument User: Uid</strong> settings page has a lot going on, but only a few things that need our attention.</li>
|
||||
<li>The <strong>Title</strong> field here, unlike the Title field under <em>Basic Settings</em>, can be based upon the context that the view is being displayed in. Change the title to 'Recent entries by %1.' %1 will later be expanded to the user's name (based on the User: Uid argument) when the view is displayed.</li>
|
||||
<li>Under <strong>Action to take if argument is not present</strong>, there are a variety of options, ranging from displaying a 404 or a 403 page to simply displaying all values in the view. In our case, if an argument isn't specified (which it won't be, since this view will be displayed in a sidebar block, not as a page with its own URL), we want to give it a default one to act on. Select <em>Provide default argument</em>.</li>
|
||||
<li>Assuming JavaScript is enabled in your browser, you should now get another selection for <strong>Default argument type</strong>. Select <em>User ID from URL</em>, which will then provide a new option, <em>Also look for a node and use the node author</em>. Select it. This will cause Views to first see if it can figure out a user ID from the current URL (for example, user/1). If it can't, it will instead check to see if the current page is a node page (such as node/42) and, if so, take the user ID from the node's author field instead.</li>
|
||||
<li><strong>Validator options</strong> provide a useful way to control what kind of arguments your view will accept. Select <em>User</em> as the <strong>Validator</strong>. By default, changing this setting will check the incoming argument and ensure it's a valid user ID; if not, the view will be hidden from the page.</li>
|
||||
<li>Once you have changed the argument's title, default argument, and validator options, click <strong>Update</strong> to save your changes.</li>
|
||||
<li>You'll notice that now the Live preview no longer shows anything. Did we just break the view? Fortunately, no. It's merely abiding by our wishes to hide itself if there is no valid user ID given to it. Try entering a '1' in the <strong>Arguments</strong> box and clicking <strong>Preview</strong>. You should now see a list of only user 1's blog entries.</li>
|
||||
</ol>
|
||||
|
||||
<h3>Creating the block</h3>
|
||||
<p>So the live preview is now showing basically what we want. There's just one problem: we have no way to stick what we've done so far into a sidebar block! Let's fix that by adding a new <strong>Display</strong>.</p>
|
||||
|
||||
<ol>
|
||||
<li>In the first column, under <strong>Defaults</strong>, there is a select box containing entries such as <em>Page</em>, <em>Feed</em>, and, yes, <em>Block</em>! Select <em>Block</em> and click <strong>Add display</strong>.</li>
|
||||
<li>There's not much else to do here as far as Views is concerned. Under <strong>Block settings</strong>, click the <em>None</em> link next to <strong>Admin</strong> and fill in a description for the block in the administrative interface, such as: 'Recent blog entries by author.' and click <strong>Update</strong>.</li>
|
||||
<li>Save your work by clicking the <strong>Save</strong> button at the bottom of the Views interface. You should receive a message that the view has been saved.</li>
|
||||
<li>Next, navigate to the <a target="_blank" href="/admin/build/block">blocks interface</a> and drag the 'Recent blog entries by author' block to the right sidebar region (or similar) and click <strong>Save blocks</strong>.</li>
|
||||
<li>You'll notice this appeared to do nothing. No block shows in the sidebar. But remember, we are looking at an adminitrative page; we are not looking at a page that would provide a user ID context. Navigate to the <a target="_blank" href="/blog">main blog listing</a> and click on an entry there. You should now see a sidebar block, titled something like "Recent entries by admin," with a list of blog entries beneath it.</li>
|
||||
</ol>
|
||||
|
||||
<h3>Finishing touches</h3>
|
||||
<p>There are still a few remaining things to do before our view is complete. For example, we said that the block was to show <em>recent</em> blog entries, but instead it's showing them in the order they were entered, with oldest on top. Additionally, even unpublished entries are showing in the list currently.</p>
|
||||
|
||||
<ol>
|
||||
<li>Return to the <a target="_blank" href="/admin/build/views/edit/recent_blog_entries">recent_blog_entries view edit page</a>.</li>
|
||||
<li>Add an additional filter by clicking the <strong>+</strong> icon in the <strong>Filters</strong> section in the fourth column.</li>
|
||||
<li>Change <strong>Groups</strong> to <em>Node</em> and select <em>Node: Published</em>. Click <strong>Add</strong>.</li>
|
||||
<li>Under the <strong>Published</strong> selection, choose <em>Yes</em> and click <strong>Update</strong>.</li>
|
||||
<li>To handle sorting, locate the <strong>Sort criteria</strong> area, just above filters, and click the <strong>+</strong> icon there.</li>
|
||||
<li>Under <strong>Groups</strong>, again select <em>Node</em>. From the list of options, check <em>Node: Post date</em> and click <strong>Add</strong>.</li>
|
||||
<li>In the settings page, change <strong>Sort order</strong> to <em>Descending</em>. This will place the newer posts on top of the older ones. Click <strong>Update</strong> when finished.</li>
|
||||
<li>Finally, <strong>Save</strong> the view for your new settings to take effect.</li>
|
||||
</ol>
|
57
modules/views/help/example-recent-stories.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
In this example you will create a list of nodes of the content type "story", to be shown in a block. Through this step-by-step process, you will become familiar with some basic steps in creating a view, and familiarize yourself with the Views User Interface.
|
||||
|
||||
<ol>
|
||||
<li><h3>Creating a new view</h3>
|
||||
<p>Go to <a target="_blank" href="base_url:admin/build/views/add">add new view</a>. Give your new view the name 'recent_stories', description 'Recent Stories', tag 'story', type 'Node' and click <strong>Next</strong>.</p></li>
|
||||
<li><h3>About the interface</h3>
|
||||
<p>You have been brought to Views User Interface. As you start, you are editing the "Default" options for the view. In the 1st column on the left you can see the drop-down menu offers 'block', for example, to select settings specific only to block views. In the remaining columns, you will be able to add or change options by clicking on links or icons. These options will then appear below this main area. Most likely, you will need to scroll a bit to see the options appear.</p></li>
|
||||
<li><h3>Selecting the fields to display</h3>
|
||||
<ol>
|
||||
<li>In 3rd column locate the <strong>Fields</strong> options. Click the <strong>+</strong> icon to add fields.</li>
|
||||
<li>Scroll down to <strong>Defaults: Add fields</strong>. In the <strong>Groups</strong> drop-down menu select 'Node', then check the following two fields: <em>Node: Post date</em>, <em>Node: Title</em>. Then click <strong>Add</strong>.</li>
|
||||
<li>You will be taken through the fields you added one at a time. Make the changes specified below.
|
||||
<ul>
|
||||
<li>For the <em>Post date</em> field: Delete the 'Post date' label. Change the <strong>Date format</strong> to <em>Custom</em>, and the <strong>Custom date format</strong> to 'F j, Y, g:i a' (do not type the single quotes; for the meaning of these letter codes, click on <em>the PHP docs</em> link under that box to arrive at the explanation). Click <strong>Update</strong>.</li>
|
||||
<li>For the <em>Title</em> field: Delete the 'Title' label. Select <em>Link this field to its node.</em> Click <strong>Update</strong>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Scroll back up to <strong>Fields</strong> and click the <strong>↑↓</strong> icon to rearrange fields.</li>
|
||||
<li>Drag the four-sided arrow next to <em>Node: Title</em> so that it appears above <em>Node: Post date</em>. Click <strong>Update</strong> to save the new field order.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Filtering to <em>story</em> nodes only</h3>
|
||||
<ol>
|
||||
<li>Click the <strong>+</strong> icon next to <strong>Filters</strong>.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu select 'Node', then check the <em>Node: Published</em> and <em>Node: Type</em> filters, and click <strong>Add</strong>.</li>
|
||||
<li>Select the <em>Published</em> checkbox. Click <strong>Update</strong></li>
|
||||
<li>Select <em>Is one of</em> and check <em>Story</em> in the <em>Node Type</em> field. Click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Sorting to show most recent first</h3>
|
||||
<ol>
|
||||
<li>Scroll up to <strong>Sort criteria</strong> and click the <strong>+</strong> icon.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu below, select 'Node', then check <em>Node: Post date</em>, and click <strong>Add</strong>. Alternatively, you may instead check <em>Node: Last comment time</em>, or <em>Node: Updated/commented date</em>, or <em>Node: Updated date</em>.</li>
|
||||
<li>Select <em>Descending</em> <strong>Sort order</strong>. Click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Refining the basic settings</h3>
|
||||
<ul>
|
||||
<li>In 1st column under <strong>Basic settings</strong> locate these options:
|
||||
<ul>
|
||||
<li><em>Items to Display</em> setting, click <em>10</em>. Change the '10' to '4'. Click <strong>Update</strong></li>
|
||||
<li><em>Style</em> setting, click <em>Unformatted</em>. Change to <em>List</em>. Click <strong>Update</strong>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h3>Adding a block display for custom options</h3>
|
||||
<ol>
|
||||
<li>In the dropdown on the left, ensure that <em>Block</em> is selected, and click <strong>Add Display</strong>.</li>
|
||||
<li>Under <strong>Block settings</strong>, click the <em>None</em> link next to the <em>Admin</em> setting. Change <strong>Block: Block admin description</strong> to 'Recent Stories'.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Saving the view</h3>
|
||||
<p>Click <strong>Save</strong> to save your work.</p></li>
|
||||
<li><h3>Instructing Drupal to show the block</h3>
|
||||
<p>Finally, you should tell Drupal to show this block. Configure your block by going to <a target="_blank" href="base_url:admin/build/block">admin/build/block</a>. Locate the block in the list: it is labeled <em>Recent Stories</em>. Place this block in a region and click <strong>Save</strong>. You may click <em>Configure</em> to set a different title, to determine which roles can view the block, and on which pages it appears; If you want your block on the front page only, enter '<front>'.</p></li>
|
||||
</ol>
|
73
modules/views/help/example-user-feed.html
Normal file
|
@ -0,0 +1,73 @@
|
|||
<p>In this example you will create a <em>Feed display</em> to show nodes by individual users, dynamically selected through the URL. You will become familiar with the Views 2 interface, as well as learn how to use an argument to pull in a user name and use it in a dynamically created path.</p>
|
||||
<p>A <em>feed</em> is a data format that places your site's content into a file that can be read and displayed by news reader programs. When visiting a site, you may notice a small <a href="http://drupal.org/misc/feed.png">RSS transmission icon</a>, whereby clicking on it, you can subscribe to the site's most recent content. This makes it easier for your visitors to keep up to date with your website. You can also use this format to aggregate information into other sites. For more information, please watch a video from Common Craft about <a href="http://www.commoncraft.com/rss_plain_english">RSS in plain English</a>.</p>
|
||||
<p>Note, Drupal automatically creates a feed for your website, but you may want to create feeds with specific information. In this case, a list per user. </p>
|
||||
<ol>
|
||||
<li>
|
||||
<h3>Creating a new view </h3>
|
||||
<ol>
|
||||
<li>Go to <a target="_blank" href="/admin/build/views/add">add new view</a>. Give it the name 'user_feed', description 'A feed of user nodes.', tag 'users', type 'Node' and click Next.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><strong>About the Interface.</strong> You have been brought to the Views User Interface. As you start, you are editing the "Default" options for the view. In the 1st column on the left- you can see the pull-down menu offers 'Feed', for example, to select settings specific only to RSS views. In the remaining columns, you will be able to add or change options by clicking on links or icons. These options appear below this main area. Most likely, you will need to scroll to see the options appear. As you make changes, these options will appear in bold until you save your view.</li>
|
||||
<li>
|
||||
<h3>Change default display</h3>
|
||||
<ol>
|
||||
<li>Under <strong>Basic Settings</strong> in the 2nd column, click <em>Row style: Fields</em></li>
|
||||
<li>A menu loads below, <em>Defaults: How should each row in this view be styled</em>, check the <em>Node</em> option, and click <strong>Update</strong>.</li>
|
||||
<li>This loads another options menu, <em>Defaults: Row style options</em> click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Create the RSS view </h3>
|
||||
<ol>
|
||||
<li>In the 1st column, select 'Feed' in the drop-down menu, and click <strong>Add Display</strong>.</li>
|
||||
<li>Under <strong>Basic Settings </strong>in the 2nd column, click<em> Row style:Missing style plugin</em></li>
|
||||
<li>Note, options appear below the Views Interface, you may need to scroll to see <em>Feed: How should each row in this view be styled</em><br />
|
||||
tick <strong>Node</strong>, then <strong>Update</strong></li>
|
||||
<li>This loads the next options menu- <em>Display type: </em>select "Use default RSS settings", click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Set the path for accessing your feed</h3>
|
||||
<ol>
|
||||
<li> In the 2nd column under <strong>Feed settings</strong>, click <em>Path: None </em></li>
|
||||
<li>In options below <em>Feed: The menu path or URL of this view</em> enter in the path with an argument feeds/%/rss.xml</li>
|
||||
<li>Click <strong>Update</strong></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Set up your arguments to say which user's nodes to display</h3>
|
||||
<ol>
|
||||
<li>To the right of <strong>Arguments</strong>, click the + sign to add and argument</li>
|
||||
<li>In the Feed: Add arguments menu that loads below, select User in the pull-down menu</li>
|
||||
<li>Check the box <em>User: Name</em>, click <strong>Add</strong></li>
|
||||
<li>Scroll down to options to find <strong>Case in path:</strong> select <em>Lower case</em></li>
|
||||
<li>Check the box <em>Transform spaces to dashes in URL</em></li>
|
||||
<li>Click <strong>Update default display</strong></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Sort to show most recent at top of feed</h3>
|
||||
<ol>
|
||||
<li>Scroll up to <strong>Sort criteria</strong> in the right most column and click the + icon.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu below, select 'Node', then check <em>Node: Post date</em>, and click <strong>Add</strong>. </li>
|
||||
<li>Select <em>Descending</em> <strong>Sort order</strong>. Click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Set filters to hide unpublished entries</h3>
|
||||
<ol>
|
||||
<li>Click the + icon next to <strong>Filters</strong>. In the options below, select <em>Node</em> under <strong>Groups</strong> drop-down menu, choose the <em>Node: Published</em> filter, and click <strong>Add</strong>.</li>
|
||||
<li>Check the box <em>Published</em>. Click <strong>Update default display</strong></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Test</h3>
|
||||
<ol>
|
||||
<li>Click <strong>Save</strong></li>
|
||||
<li>Under <strong>Live preview</strong> type in the name of a user, in lowercase, replacing spaces with dashes, click <strong>Preview</strong>.</li>
|
||||
<li>You should test and find your feeds at URLs like http://yoursite.com/feeds/user-name/rss.xml</li>
|
||||
<li>You can use this path for aggregating on another site. You can also attach the RSS feed to another display of view to make the feed link appear on that display.</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
47
modules/views/help/example-users-by-role.html
Normal file
|
@ -0,0 +1,47 @@
|
|||
In this example you will create a page view listing users on your site. Through this step-by-step process, you will become familiar with some basic steps in creating a view, and familiarize yourself with the Views User Interface.
|
||||
|
||||
<ol>
|
||||
<li><h3>Creating a new view</h3>
|
||||
<p>Go to <a target="_blank" href="base_url:admin/build/views/add">add new view</a>. Give your new view the name 'user_list', description 'A simple user listing.', tag 'users', type 'User' and click <strong>Next</strong>.</p></li>
|
||||
<li><h3>About the Interface</h3>
|
||||
<p>You have been brought to the Views User Interface. As you start, you are editing the "Default" options for the view. In the 1st column on the left you can see the drop-down menu offers 'block', for example, to select settings specific only to block views. In the remaining columns, you will be able to add or change options by clicking on links or icons. These options will then appear below this main area. Most likely, you will need to scroll to see the options appear. As you make changes, these options will appear in bold until you save your view.</p></li>
|
||||
<li><h3>Creating a page display; choosing a URL and creating a menu link</h3>
|
||||
<ol>
|
||||
<li>In the 1st column, ensure that 'Page' is selected in the drop-down menu, and click <strong>Add Display</strong>.</li>
|
||||
<li>Next we'll define the path for this page. A page must have a path, and we define it early so that Views doesn't warn us "Display Page uses path but path is undefined." Locate the <strong>Page settings</strong> in the 2nd column, and click the <em>None</em> link next to the <em>Path</em> setting. In the options editing area that appears below, set the path to 'user_list' (or something else if you prefer) and click <strong>Update</strong>.</li>
|
||||
<li>Next to <em>Menu</em> setting, Click the <em>No menu</em> link. In the options which appear below, select <em>Normal menu entry</em>, and set the title to 'User list' and click <strong>Update</strong>.</li>
|
||||
<li>Scroll up to <strong>Basic settings</strong>, in that same 2nd column, and click the <em>No</em> link next to <em>Use pager</em>. Below, in the options, select <em>Full pager</em> and click <strong>Update default display</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Selecting the fields to display</h3>
|
||||
<ol>
|
||||
<li>In 3rd column locate the <strong>Fields</strong> options. Click the <strong>+</strong> icon to add fields.</li>
|
||||
<li>Scroll down to <strong>Defaults: Add fields</strong>. In the <strong>Groups</strong> drop-down menu select 'User', then check the following fields: <em>User: Created date</em>, <em>User: Delete link</em>, <em>User: Edit link</em>, <em>User: Last access</em>, <em>User: Name</em> and <em>User: Picture</em>. Then click <strong>Add</strong>.</li>
|
||||
<li>You will be taken through the fields you added one at a time. Click <strong>Update default display</strong> to go to each next field. Leave the default options on all fields except <em>Delete link</em>; change that field's label to 'Operations'.</li>
|
||||
<li>Scroll back up to <strong>Fields</strong> and click the <strong>↑↓</strong> icon to rearrange fields. Down below, drag the <em>Name</em> field, by dragging its four-sided arrow, to the top. Drag the <em>Delete link (Operations)</em> field to the bottom, and the <em>Edit link</em> field just above it. Then click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Seeing what we've done so far</h3>
|
||||
<p>At this point, you have done enough to create a valid view. If you scroll down, you will see a preview of your view. If it doesn't show already, click the <strong>Preview</strong> button; but generally this display updates automatically whenever you finish working in one of the mini forms.</p></li>
|
||||
<li><h3>Styling the view as a table; combining related fields into columns</h3>
|
||||
<ol>
|
||||
<li>Under <strong>Basic settings</strong>, in the 1st column, click the <em>Unformatted</em> link next to the <em>Style</em> setting. In the options below, under <strong>Page: How should this view be styled</strong>, choose <em>Table</em> and click <strong>Update default display</strong>.</li>
|
||||
<li>You will be taken to a <strong>Page: Style options</strong> form to edit the table settings. Locate our <em>Edit link</em> field in this mini form, and notice the <strong>Column</strong> drop-down. Change this drop-down to show <em>Operations</em>. In the <strong>Separator</strong> column next to the <em>Operations</em> field, type ' | ' (note the spaces around the <strong>|</strong> symbol). Check all of the <strong>Sortable</strong> checkboxes, and set <strong>Default sort</strong> to <em>Name</em>. When finished, click <strong>Update default display</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Filtering the user list to exclude unwanted entries</h3>
|
||||
<ol>
|
||||
<li>Click the <strong>+</strong> icon next to <strong>Filters</strong>.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu select 'User', then check the <em>User: Name</em> filter, and click <strong>Add</strong>.</li>
|
||||
<li>Select <em>Is not one of</em> and enter 'Anonymous' in the <strong>Usernames</strong> box. Click <strong>Update default display</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Adding an argument to list users by role dynamically</h3>
|
||||
<ol>
|
||||
<li>Scroll up to <strong>Arguments</strong>, and click its <strong>+</strong> icon.</li>
|
||||
<li>Check the <em>User: Roles</em> argument, and click <strong>Add</strong>. Set the title to '%1' (don't type the quotes), and under <strong>Action to take if argument is not present</strong> select <em>Summary, sorted ascending</em>. Leave the other settings as they are. Click <strong>Update default display</strong>, and click <strong>Update</strong> through the prompts that follow to accept their default values.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Saving the view</h3>
|
||||
<p>Finally, click the <strong>Save</strong> button to save your work. At the very top, click <strong>View "Page"</strong> to go to your new view!</p></li>
|
||||
</ol>
|
5
modules/views/help/field.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
Fields are the individual pieces of data being displayed. Adding the fields <em>Node: Title</em>, <em>Node: Type</em>, and <em>Node: Post date</em> to a node view, for example, includes the title, content type and creation date in the displayed results).
|
||||
|
||||
Fields may not appear on every display, because not all style plugins actually use fields. For example, the 'node' row plugin simply displays the node through Drupal's normal mechanisms, and fields are not involved.
|
||||
|
||||
For the most part, the field settings should be self explanatory. Fields will appear in the order that they are arranged in, and they will usually appear with the label they are given.
|
12
modules/views/help/filter.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
Filters are used to reduce the data set that Views provides. That is to say, without any filters applied, Views will return all of your content. You don't want that, so at least some filters must be used.
|
||||
|
||||
Some very commonly used filters:
|
||||
<ul>
|
||||
<li> The 'Node: Published' filter is used to restrict a node View to only nodes that are are have the 'published' box checked. This can be very important to prevent users from viewing content they should not have access to.</li>
|
||||
<li> The 'Node: Promoted to front page' filter can be used to show only nodes that have the 'promote to front page' turned on. </li>
|
||||
<li> The 'Node: Type' filter is useful for showing only certain types of nodes. Let's say you wanted users to see only nodes that were 'book' nodes, or a combination of 'book' nodes and 'staff-blog' nodes. This filter allows you to select exactly that.</li>
|
||||
<li> The 'User: Current' filter will show only nodes that the logged in user has authored.</li>
|
||||
<li> The 'Node: Post date' filter can be used to show only nodes posted before, after, or between a range of dates.</li>
|
||||
</ul>
|
||||
|
||||
The above list is only a tiny fraction of the filters available in Views, referenced here to give an idea of the kinds of tasks filters can accomplish.
|
26
modules/views/help/getting-started.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
Module Developers:
|
||||
The Views' API help pages can be found <a href="topic:views/api">here</a>.
|
||||
|
||||
New Users:
|
||||
For those new to Views, it can be a complex system that appears totally overwhelming. The good news is that the UI is designed to compartmentalize everything; this means that for the most part, you can ignore the parts you're not interested in. Start small and build your way up.
|
||||
|
||||
Because of this, the edit UI can seem overwhelming at first, but there are really just a few things you <strong>have</strong> to know. The rest you can find through exploration. The Views Edit UI image, below, gives an overview of what you'll find on the edit UI.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/overview-ui-large.png"><img src="path:images/overview-ui-small.png" /></a>
|
||||
<em>The Views Edit UI</em>
|
||||
</div>
|
||||
|
||||
Notes:
|
||||
1) Every view has a number of <a href="topic:views/display">displays</a> which represent where output will be placed. If you're familiar with the original Views 1, you could set a view to be a 'page', with a URL (path), or a block that could show up in a sidebar. With Views 2, you can add as many displays as you like. In addition, you have the <em>default</em> display which contains the basic settings, but doesn't actually show up anywhere.
|
||||
|
||||
2) When you click on the link for an item, a form will open up. For browsers with smaller resolutions, you may have to scroll down a little to see this form. If a form is open, the item its attached to will be highlighted.
|
||||
|
||||
3) <a href="topic:views/overrides">Overrides</a> mean that a particular display is <strong>not</strong> using default settings. When you create a new display, many of its settings will start off using default values. This will be indicated by italics and a lighter color. <strong>If you change these values without first overriding them, you will change the default value for all displays that use them.</strong>
|
||||
|
||||
4) Some items, particularly styles, have additional settings. Ordinarily when you <em>update</em> a style, if it has additional settings you will automatically see that form next. Often, you will need to go directly to those settings.
|
||||
|
||||
5) You can safely leave a view page to go and do other things. If you come back, the view will still be there, stored in a cache. Keep in mind, however, that while you do this, that view is <em>locked</em>, meaning another user cannot edit this view without breaking the lock. Breaking the lock will discard your changes.
|
||||
|
||||
It helps to have something particular in mind that you want to accomplish when using Views. Here are a couple of ideas and a brief sketch of how to accomplish what you want.
|
||||
|
BIN
modules/views/help/images/node-term_node-term_data-large.png
Normal file
After Width: | Height: | Size: 4 KiB |
BIN
modules/views/help/images/node-term_node-term_data.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
modules/views/help/images/overview-ui-large.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
modules/views/help/images/overview-ui-small.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
modules/views/help/images/style-breakdown-large.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
modules/views/help/images/style-breakdown.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
modules/views/help/images/views1-admin-large.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
modules/views/help/images/views1-admin.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
modules/views/help/images/views1-changeviewtype-large.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
modules/views/help/images/views1-changeviewtype.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
modules/views/help/images/views2-addaview-large.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
modules/views/help/images/views2-addaview.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
modules/views/help/images/views2-adddisplay-large.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
modules/views/help/images/views2-adddisplay.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
modules/views/help/images/views2-addfields-large.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
modules/views/help/images/views2-addfields.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
modules/views/help/images/views2-addfieldsajax-large.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
modules/views/help/images/views2-addfieldsajax.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
modules/views/help/images/views2-admin-large.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
modules/views/help/images/views2-admin.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
modules/views/help/images/views2-changedisplaystyle-large.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
modules/views/help/images/views2-changedisplaystyle.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
modules/views/help/images/views2-fieldspreview-large.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
modules/views/help/images/views2-fieldspreview.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
modules/views/help/images/views2-newview-large.png
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
modules/views/help/images/views2-newview.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
modules/views/help/images/views2-rearrangefields-large.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
modules/views/help/images/views2-rearrangefields.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
modules/views/help/images/views2-tablestyle-large.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
modules/views/help/images/views2-tablestyle.png
Normal file
After Width: | Height: | Size: 20 KiB |
21
modules/views/help/menu.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
Page displays can hook into the Drupal menu system and provide <strong>menu links</strong> that will appear in the Navigation system as well as <strong>tabs</strong> that can be used to keep Views next to each other.
|
||||
|
||||
For simple <strong>menu links</strong>, there is very little you need to do; simply select 'Normal menu entry' and fill in the text for the title. This will appear in the Navigation menu by default; you will need to visit the menu administration page to move this to another menu.
|
||||
|
||||
Tabs are not quite so simple; there are some complex rules for using tabs in Drupal.
|
||||
<ol>
|
||||
<li> All tabs must have a parent, which is the next level up in the path hierarchy. For example, if the view path is 'example/taba' then the parent must be 'example'.
|
||||
<li> All tabs must have one and only one default tab; this is usually the same content as the parent.
|
||||
<li> If a parent does not exist, when creating the 'default' tab, Views will allow you to also create a parent item. It will automatically set up the URL for you when it does this.
|
||||
<li> Tab weight is used to control what order the tabs are displayed in. Lower numbers will display more to the left. For tabs whose numbers are the same, they will be displayed alphabetically.
|
||||
<li> Drupal only supports 2 levels of tabs, so be careful about trying to put tabs within tabs within tabs. That won't work.
|
||||
</ol>
|
||||
|
||||
For example, if you have two views that you want to be tabs, you could set it up like this:
|
||||
<ul>
|
||||
<li> In the first view, set the path to 'tabs/tab1'. Set it to be the 'default tab', set the title to 'Tab 1' and the weight to 0.
|
||||
<li> Click update and you will be taken to a form that lets you define the parent. Since 'tabs' doesn't already exist in the system, select 'Normal menu item', and set the title to 'Tabs'.
|
||||
<li> On the second view, set the path to 'tabs/tab2'; set it to be a 'Menu tab', and set the title to 'Tab 2'.
|
||||
</ul>
|
||||
|
||||
With this done, you will now have a Navigation link named 'Tabs' and when you click on it, you will go to the tabs, with 'Tab 1' being the default tab that appears. You can then click between Tab 1 and Tab 2.
|
113
modules/views/help/new.html
Normal file
|
@ -0,0 +1,113 @@
|
|||
Views 2 is the newest major release of Views and it is specifically coded for Drupal 6. Views 2 retains all of the core functionality of Views 1, together with a completely revamped user interface and a large set of new features which greatly expand upon the original feature-set of Views 1. This document is a side-by-side comparison of Views 1 versus Views 2 from a user's perspective, detailing the UI changes, some new ways to perform old tasks, the cool new features of Views 2 and how these features can be used to address some of the shortcomings of Views 1.
|
||||
|
||||
<h2>Admin interface</h2>
|
||||
The first thing that pops out after you install Views 2 is the radically different admin interface:
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-admin-large.png"><img src="path:images/views2-admin.png" /></a>
|
||||
<em>Views 2 admin interface</em>
|
||||
</div>
|
||||
|
||||
compared to the old comfy Views 1 interface:
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views1-admin-large.png"><img src="path:images/views1-admin.png" /></a>
|
||||
<em>Views 1 admin interface</em>
|
||||
</div>
|
||||
|
||||
The new admin interface performs the same functions as the old -- listing all the views in the system, providing links to add or import views and a link to Views Tools -- but has been compacted, with each view displayed as a paragraph style-row compared to the table of Views 1 and set of filters on top to ease locating views among a large list.
|
||||
|
||||
Context-help is available by clicking the small blue question-mark icon. Context-help in Views 2 is provided by the <a href="http://drupal.org/project/advanced_help">Advanced Help</a> module, so make sure to install that together with installing Views 2. The small blue help icons will be available in various parts of the Views UI. In particular, look for them as part of the description of a <strong>display</strong>, when setting <strong>style</strong> options, and in various editing sections such as <strong>path</strong>, <strong>menu</strong> and the like.
|
||||
|
||||
Several new attributes of each view are visible in the filter header:
|
||||
<ol>
|
||||
<li><strong>Tag</strong> - This is just another label for organizing and sorting views. Tags can be any text. Views that are provided by modules will often be tagged together to make it easy to find them. Tags are also added to your template suggestions, so take care what you set here. For example setting the tag <i>Page</i> will give all your views the Page template.</li>
|
||||
<li><strong>Display</strong> - In Views 1 each view query was tied to its display; in other words your fields, sorts, filters, and arguments could only be displayed in the single page or block display provided in the view definition. In Views 2, view displays have been decoupled from view queries - it is now possible to have multiple page, block, and feed displays from a single view. More on view displays later. </li>
|
||||
<li><strong>Type</strong> - Views 2 view types are radically different from Views 1 types. Views 1 types basically defined how the node list displays were <i>styled</i> - you had Full Nodes, Teaser List, Table View, and so on. In Views 2 view display styles have been broken out into the separate <i>Style</i> attribute. View types now refer to the primary table on which information for the query will be retrieved which controls what arguments, fields, sort criteria and filters are available. Views 2 view types are discussed later.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h2>Adding a view</h2>
|
||||
So let's jump in and add a view. For this example, we're going to create a <strong>user</strong> view, which will display a list of users.
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-addaview-large.png"><img src="path:images/views2-addaview.png" /></a>
|
||||
<em>Adding a view</em>
|
||||
</div>
|
||||
|
||||
The first step in adding a view is simply entering a name (only alphanumeric characters, no spaces) a description, tag, and the view type. To get the user view, we selected the <strong>User</strong> radio button.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-newview-large.png"><img src="path:images/views2-newview.png" /></a>
|
||||
<em>Configuring the new view</em>
|
||||
</div>
|
||||
|
||||
This might be the 2nd whoa moment as the interface here is also completely revamped from Views 1.x. The best way to summarize is to say all the pieces from the Views 1.x interface are still there...just in different places. Fields, arguments, sort critera and filters are all still there there, just in new AJAXY-flavours.
|
||||
|
||||
Let's start by adding some fields:
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-addfields-large.png"><img src="path:images/views2-addfields.png" /></a>
|
||||
<em>Adding fields</em>
|
||||
</div>
|
||||
|
||||
Clicking on the [+] icon next to the word Fields unfurls a section beneath the view information with all the available fields grouped by Comment, File, Node, Node revision, Taxonomy and User, and probably a few others. This is a general paradigm for the Views 2 interface -- clicking on a widget or link unfurls a section beneath the view information with the relevant interface. Usually, what is being edited will be hilited in yellow, as well.
|
||||
|
||||
When adding items, you can use the Groups drop-down box to show only a subset of the fields available according to the above groups, or select All to see all fields available, which is what was selected when the section unfurled. For our example, we're selecting the 'User' group and adding the <strong>User: E-mail</strong>, <strong>User: Name</strong> and <strong>User: Picture</strong> fields.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-addfieldsajax-large.png"><img src="path:images/views2-addfieldsajax.png" /></a>
|
||||
<em>Adding fields</em>
|
||||
</div>
|
||||
|
||||
Once we add our fields they show up in the Fields section of the interface. We will be walked through each field we added, so keep clicking <strong>update</strong>, even if you don't make changes to the field and you will see the next one.
|
||||
|
||||
The fields we added can be rearranged by clicking the up/down icon, right next to the add icon we used earlier. We can also remove a field using the same interface.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-rearrangefields-large.png"><img src="path:images/views2-rearrangefields.png" /></a>
|
||||
<em>Rearranging fields</em>
|
||||
</div>
|
||||
|
||||
From here, the fields can be dragged up and down by grabbing the little drag handle on the left and moving them where you like. Making a change to any part of the view by clicking update usually triggers a refresh of the view preview which is conveniently located right below the main interface.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-fieldspreview-large.png"><img src="path:images/views2-fieldspreview.png" /></a>
|
||||
<em>Views preview</em>
|
||||
</div>
|
||||
|
||||
Now that we have some fields set up we can turn our attention to Basic Settings for the view.
|
||||
|
||||
It's important to note that all the interface elements pertain to the current <i>Display</i> selected for the view. As mentioned before a view can have multiple displays. The first time you create a view you'll be manipulating the <i>Default</i> display. You can add displays using the Add Display button, whose Basic Settings are completely different from each other; this lets you have as many displays of a view as you would like all sharing items such as Sort Criteria, Filters and Arguments but different display settings like Title, Style, Fields, and Pager settings. Also, any display you add automatically inherits display settings from the default display initially, so you can keep a core of common settings in your default display and add additional settings for every other display.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-adddisplay-large.png"><img src="path:images/views2-adddisplay.png" /></a>
|
||||
<em>Adding a <strong>Page</strong> display </em>
|
||||
</div>
|
||||
Let's stick with the Default display and twiddle some settings. We can set the <i>Title</i> to "User View 1" and the <i>Style</i> to Table. As mentioned earlier, view styles in Views 2 correspond more to view types in Views 1 (remember, List, Table, Teasers, Full nodes).
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views1-changeviewtype-large.png"><img src="path:images/views1-changeviewtype.png" /></a>
|
||||
<em>Selecting a Views 1 View Type</em>
|
||||
</div>
|
||||
|
||||
In Views 2, view <i>styles</i> control how a view display looks. These styles are significantly different from the Types in Views 1; in particular, types have been 'broken up'; there is now the <em>style</em> as well as the <em>row style</em> which focus on different parts of the output.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/style-breakdown-large.png"><img src="path:images/style-breakdown.png" /></a>
|
||||
<em>A breakdown of View output</em>
|
||||
</div>
|
||||
|
||||
We change the style by clicking on the current style on the left hand side of the View information area.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-changedisplaystyle-large.png"><img src="path:images/views2-changedisplaystyle.png" /></a>
|
||||
<em>Selecting a Views 2 Display Style</em>
|
||||
</div>
|
||||
|
||||
We're given the style options of <strong>Grid</strong>, <strong>List</strong>, <strong>Table</strong> and <strong>Unformatted</strong>. Additional display styles can be added by modules which have Views <i>style plugins</i>. Choosing a style reveals a "settings" button which you can click to configure the style you've chosen. In the shot below we've selected and are configuring the Table style, which we're using to produce a more compact output than we had earlier.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/views2-tablestyle-large.png"><img src="path:images/views2-tablestyle.png" /></a>
|
||||
<em>Selecting and configuring the table style</em>
|
||||
</div>
|
||||
|
||||
... TODO: Finish this document ...
|
6
modules/views/help/overrides.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
If an item is <strong>using defaults</strong> then it is using values from the <strong>default display</strong>. <em>IMPORTANT NOTE:</em> If you modify this value, you are modifying the <strong>default display</strong> and thus modifying for all displays that are using default values.
|
||||
|
||||
If that is not what you intend, you must click the <strong>override</strong> button. Once overridden, that display now has its own version of the value; modifying it will not modify it for other displays.
|
||||
|
||||
For <strong>Relationships</strong>, <strong>arguments</strong>, <strong>fields</strong>, <strong>sort criteria</strong>, and <strong>filters</strong>, each of these must be overridden as a group! In other words, you cannot override a single filter, but instead must override all filters. A message will appear on the item to let you know what its status is, but you can only change the status by clicking on the header or the rearrange button for that item.
|
7
modules/views/help/path.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
If a display has a path that means that it can be retrieved directly by calling a URL as a first class page on your Drupal site. Any items after the path will be passed into the view as arguments. For example, if the path is <strong>foo/bar</strong> and a user visits <strong>http://www.example.com/foo/bar/baz/beta</strong>, 'baz' and 'beta' will be given as arguments to the view. These can be handled by adding items to the <a href="topic:views/arguments">arguments</a> section.
|
||||
|
||||
You may also use placeholders in your path to represent arguments that come in the middle. For example, the path <strong>node/%/someview</strong> would expect the first argument to be the second part of the path. For example, <strong>node/21/someview</strong> would have an argument of '21'.
|
||||
|
||||
<em>Note:</em> Views 1 used <strong>$arg</strong> for this kind of thing. $arg is no longer allowed as part of the path. You must use % instead.
|
||||
|
||||
If multiple displays <strong>within the same view</strong> have the same path, the user will get the first display they have access to. This means you can create successfuly less restricted displays in order to give administrators and privileged users different content at the same path.
|
13
modules/views/help/relationship.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
Relationships allow you to expand the query to include objects other than the base query. This is actually made more difficult to understand by the fact that Views actually includes a few relationships by default, and doesn't tell you they're there. For historical reasons, it would be inconvenient to remove these default relationships. When relationships are present, all fields (including relationships) will gain a new form item to let you select which relationship they will use. They will default to using no relationship at all.
|
||||
|
||||
The main example of the relationship that is there by default is the node --> user relationship; every node has an author, and if a node is in the query, the user who wrote that node is automatically made available. [Note: the author considers it an error that this relationship is automatic, but by the time it was realized this was in error, it was too late to change it.]
|
||||
|
||||
A similar relationship that is <b>not</b> automatically made available is for node revisions. Each revision has its own author, which is the user who made the revision. By adding the "Node revision: User" relationship, all of the 'user' fields, sorts, filters and arguments available to a user will now be available for the revision author.
|
||||
|
||||
When a relationship is added to the view, all applicable items will gain a "Relationship" select box, where you can choose which version of that particular item you wish to use. This can be illustrated with an example:
|
||||
|
||||
A 'comment' view contains the relationships 'Comment: node' and 'Comment: user'. This means that all the fields for the node that a comment is attached to are available, and all the user fields for that node author also become available. The other relationship makes fields for the author of the comment available -- very often not the author of the node!
|
||||
|
||||
When you add the "User: name" field, you will be presented with a select box. Either the node relationship or the user relationship must be selected, because there are two possible user names in the view to choose from.
|
||||
|
||||
Another example of relationships involves the <strong>Files</strong> table. In Drupal, files are related to users, but files are not necessarily related to nodes. However, the upload.module allows some files to be attached to nodes. The only way for Views to deal with this discrepancy is with relationships. When creating a 'node' view, it's possible to add an uploaded files relationship to get file data for nodes that were attached with the upload module. It is also possible to go the other way; from a files view you may add a relationship via the Upload table to view information about the node.
|
24
modules/views/help/sort.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
Sort criteria determine what order the records are retrieved from the database and displayed in; generally, all you need to do is pick a field and choose ascending (1, 2, 3, 4) or descending (4, 3, 2, 1) and it will be done. If you have multiple sort criteria, the second (and later) items only come into play if the first item is the same.
|
||||
|
||||
Different data types sort just a little bit differently from others:
|
||||
<dl>
|
||||
<dt>Number fields</dt>
|
||||
<dd>Number fields sort like you would expect. 1 comes before 2 which comes before 10 which comes before 100 which comes before 200, etc.</dd>
|
||||
<dt>Text fields</dt>
|
||||
<dd>Text fields always sort alphabetically, even if the text contains numbers. This can have some odd effects if you have numbers stored in text, because the values 1, 3, 7, 10, 12, 20, 100, 120 will sort like this:
|
||||
<ul>
|
||||
<li> 1 </li>
|
||||
<li> 10 </li>
|
||||
<li> 100 </li>
|
||||
<li> 12 </li>
|
||||
<li> 120 </li>
|
||||
<li> 200 </li>
|
||||
<li> 3 </li>
|
||||
<li> 7 </li>
|
||||
</ul>
|
||||
|
||||
This is because these fields sort purely by characters, and not numeric value. i.e, comparing 200 and 3, the '2' comes before the '3', therefore, '200' is "smaller" than '3'.
|
||||
</dd>
|
||||
<dt>Date fields</dt>
|
||||
<dd>Date fields often can have a 'granularity', which is a way of making similar dates actually be the same date. Take two dates that are close to each other: <strong>May 1, 2007 5:30 am</strong> and <strong>May 1, 2007 9:45am</strong>. Without granularity, the two dates are compared and the first date comes before the second date. However, if the granularity is set to 'day' it only looks at the parts of the date up to the day: <strong>May 1, 2007</strong> and <strong>May 1, 2007</strong>. At that point, they are the same, and the sort would move on to the next sort criterion.</dd>
|
||||
</dl>
|
1
modules/views/help/style-comment-rss.html
Normal file
|
@ -0,0 +1 @@
|
|||
This row style is only available to RSS styles. It produces XML necessary for an RSS feed for the comment.
|
5
modules/views/help/style-fields.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
The <strong>fields</strong> row style displays each field defined in the view, one after another. Each field defines its own output.
|
||||
|
||||
By default, each field is put in a <div> unless it is selected to be <em>inline</em>. If it is inline, it is put in a <span>. Two items in <div>s will be displayed one after another, with the second one below the first. Two items in <span>s will be displayed on the same line. One item in a <span> next to <div>s is the same as two items in <div>s. This means that for the <em>inline</em> setting to do anything, at least two consecutive items must be set inline.
|
||||
|
||||
You may define a separator which will be placed between each item. This separator may be html. You can use &nbsp; to print blank space.
|
20
modules/views/help/style-grid.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
The <strong>grid</strong> style will display each row of your view within a grid. You may customize the number of columns, though it defaults to 4. A grid looks like this:
|
||||
|
||||
<table width="100%">
|
||||
<tr><td>row 1</td><td>row 2</td><td>row 3</td><td>row 4</td></tr>
|
||||
<tr><td>row 5</td><td>row 6</td><td>row 7</td><td>row 8</td></tr>
|
||||
<tr><td>row 9</td><td>row 10</td><td>row 11</td><td>row 12</td></tr>
|
||||
<tr><td>row 13</td><td>row 14</td><td>row 15</td><td>row 16</td></tr>
|
||||
</table>
|
||||
|
||||
The above uses the 'horizontal' alignment, where rows are added into the grid from left to right.
|
||||
|
||||
With a vertical alignment, rows will be placed from top to bottom, like this:
|
||||
<table width="100%">
|
||||
<tr><td>row 1</td><td>row 5</td><td>row 9</td><td>row 13</td></tr>
|
||||
<tr><td>row 2</td><td>row 6</td><td>row 10</td><td>row 14</td></tr>
|
||||
<tr><td>row 3</td><td>row 7</td><td>row 11</td><td>row 15</td></tr>
|
||||
<tr><td>row 4</td><td>row 8</td><td>row 12</td><td>row 16</td></tr>
|
||||
</table>
|
||||
|
||||
This style uses a <a href="topic:views/style-row">row style</a> to determine what each row will look like.
|
20
modules/views/help/style-list.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
The <strong>List</strong> view style will display every row of the view as part of an HTML list construct. For example:
|
||||
<ul>
|
||||
<li> Row 1 </li>
|
||||
<li> Row 2 </li>
|
||||
<li> Row 3 </li>
|
||||
<li> Row 4 </li>
|
||||
</ul>
|
||||
|
||||
You may select whether or not the list is <em>ordered</em> which just means whether or not it uses numbers instead of the bullet:
|
||||
|
||||
<ol>
|
||||
<li> Row 1 </li>
|
||||
<li> Row 2 </li>
|
||||
<li> Row 3 </li>
|
||||
<li> Row 4 </li>
|
||||
</ol>
|
||||
|
||||
The list style also uses a <em>row style</em> which means that it doesn't care what the actual output for each row of the view is.
|
||||
|
||||
If you need information about using CSS to style list views, you may find this <a href="http://www.alistapart.com/stories/taminglists/">A list apart guide to styling lists</a> useful.
|
1
modules/views/help/style-node-rss.html
Normal file
|
@ -0,0 +1 @@
|
|||
This row style is only available to RSS styles. It produces XML necessary for an RSS feed for the node record.
|
9
modules/views/help/style-node.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
The <strong>node</strong> row style will display each item of the view through Drupal's standard <em>node_view()</em> function. Views has very little control over this output, except for the options you see. Instead, the output is run through the standard node template mechanism (typically <strong>node.tpl.php</strong> or a variant thereof) and any decisions about what is output may be done there.
|
||||
|
||||
Views does add an extra 'suggestion' to the list of possible node templates: <strong>node-view-VIEWNAME.tpl.php</strong> -- you may use this to theme a node specifically for the view. This can be handy for creating very small teasers and the like.
|
||||
|
||||
You may opt to display the full node body or the node teaser, and you may add the node links (such as he 'comment' links that appear after a node) or not.
|
||||
|
||||
Because of this behavior, <strong>the node row style does not utilize fields</strong> and the Fields section will not be displayed.
|
||||
|
||||
<strong>Please note that this row style performs a node_load() for every row, and as such can produce a lot of extra queries.</strong> Sometimes this is necessary, but it can have a negative impact on your site's performance!
|
3
modules/views/help/style-row.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
A row style is an individual style to display only an individual record within a view. For example, a <strong>node</strong> type view would display one node per row; a <strong>user</strong> type view would display one user per row.
|
||||
|
||||
Some row styles use <em>fields</em> which means you select from the available fields to display; others do not; they are able to use the base type and create a display. Usually, row styles that do not use fields <em>produce less efficient (slower) views</em>, so bear this in mind when contemplating the performance of your site.
|
3
modules/views/help/style-rss.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
The <strong>RSS</strong> output style is only available for <em>Feed</em> display types. It will display the view as an RSS feed, which is a specialized XML output. This output is not user visible, but can be parsed by feed readers for aggregation.
|
||||
|
||||
You may supply a description for the RSS feed; most feed readers will display this description along with the contents of the feed. You may also select to use the site's mission statement for the description.
|
3
modules/views/help/style-summary-unformatted.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
The <strong>unformatted summary</strong> style is only available for <em>summary</em> styles, which are when an argument has been set to provide a summary if it was not provided with a value. This summary provides the possible candidates for the argument one after another with no special formatting. If <em>inline</em> is selected, the summary items will be enclosed within <span> tags. Otherwise the items will be in <div> tags.
|
||||
|
||||
You can also elect to display the number of matching records for the argument, plus change the number of items per page for the summary. This is often useful because summary views are often quite small, but other views quite space intensive. It is very common to have far more records available in the summary view than in the more normal view.
|
3
modules/views/help/style-summary.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
The <strong>list summary</strong> style is only available for <em>summary</em> styles, which are when an argument has been set to provide a summary if it was not provided with a value. This summary provides a list of possible candidates for the argument in a standard HTML list. Like the normal list style, you may set this list to be ordered or not.
|
||||
|
||||
You can also elect to display the number of matching records for the argument, plus change the number of items per page for the summary. This is often useful because summary views are often quite small, but other views quite space intensive. It is very common to have far more records available in the summary view than in the more normal view.
|
13
modules/views/help/style-table.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
The <strong>table</strong> style will display the View results as a table; each row of the table will correspond to a row from the view result.
|
||||
|
||||
When setting the table options, each field in the view will be presented with some information next to each field:
|
||||
<dl>
|
||||
<dt> <strong>Column</strong> </dt>
|
||||
<dd> By default, each field is its own column. However, you can place multiple fields in the same column. To do this, pick which field you want to represent the column, then pick another field and set the 'column' value to that field. You can place as many fields as you like in a single column, but only the main field in a column can be click-sorted.</dd>
|
||||
<dt> <strong>Separator</strong> </dt>
|
||||
<dd> If you have multiple fields in the same column, the separator will be placed between each one. At the very least, &nbsp; should be used, as without the separator the fields will be placed very close to each other. Common separators are a bullet, the | symbol, and a comma. If there are no other fields in the column, the separator will have no effect.</dd>
|
||||
<dt> <strong>Sortable</strong> </dt>
|
||||
<dd> If checked, the header for the column will be clickable, and the user may re-sort the table by clicking on this to sort by that field. At this time Views does not support click-sorting to sort by multiple columns at the same time.</dd>
|
||||
<dt> <strong>Default sort</strong> </dt>
|
||||
<dd> You may select a column which will be sorted by default when the table is first viewed. This column will be highlighted to the user. You may also select whether the default sort is ascending or descending.</dd>
|
||||
</dl>
|
1
modules/views/help/style-unformatted.html
Normal file
|
@ -0,0 +1 @@
|
|||
The unformatted output style simply places each row of the view, one after another, with no additional formatting.
|
14
modules/views/help/style.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
The Views' <strong>style</strong> system is how you customize the output produced by your view. A view style is basically a smart theme template that processes the view data and then outputs it. All styles in Views can be <a href="topic:views/using-theme">overridden</a> by placing copies of the templates in your theme directory and then modifying them. See the <a href="topic:views/analyze-theme">theme: information</a> link available on all views to get hints for which templates a given view is using.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/style-breakdown-large.png"><img src="path:images/style-breakdown.png" /></a>
|
||||
<em>A breakdown of View output</em>
|
||||
</div>
|
||||
By default, the style is <em>unformatted</em>, which means that there is very little style actually used; the records are simply displayed one after another, enclosed in a <div> tag so that you can use <a href="topic:views/theme-css">CSS to manipulate the view</a>.
|
||||
|
||||
Some styles use a separate <a href="topic:views/style-row">row style</a> to determine how each row of the View looks. This is useful for mixing and matching styles to more readily produce exactly the kind of output you need.
|
||||
|
||||
Many styles can be <strong>grouped</strong>. For styles that can, there will be a 'grouping field' option; pick one of the fields to group by. This grouping field will be displayed as a header, and all rows will be displayed beneath it.
|
||||
With the Theme Developer module enabled, the field grouping in Views does not work. Disable the Theme Developer module before grouping by fields.
|
||||
|
||||
Each style is its own entity.
|
75
modules/views/help/theme-css.html
Normal file
|
@ -0,0 +1,75 @@
|
|||
Views uses a wide array of CSS classes on all of its content to ensure that you can easily and accurately select exactly the content you need in order to manipulate it with CSS.
|
||||
|
||||
Typically, every view is wrapped in a div with the name of the view as part of its class (for all these examples, we will assume the name of the view is <strong>myview</strong>), as well as the generic class 'view':
|
||||
|
||||
<pre>
|
||||
<div class="view view-myview">
|
||||
...
|
||||
</div>
|
||||
</pre>
|
||||
|
||||
In your CSS, you can modify all views:
|
||||
|
||||
<pre>
|
||||
div.view {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</pre>
|
||||
|
||||
Or just your view:
|
||||
|
||||
<pre>
|
||||
div.view-myview {
|
||||
background: yellow;
|
||||
}
|
||||
</pre>
|
||||
|
||||
By default, the general view template also provides the following classes to easily style other areas of the view:
|
||||
<ul>
|
||||
<li> .view-header </li>
|
||||
<li> .view-filters </li>
|
||||
<li> .view-content </li>
|
||||
<li> .view-empty (if an "empty" text is used when the view has no results) </li>
|
||||
<li> .view-footer </li>
|
||||
<li> .feed-icon </li>
|
||||
<li> .attachment-before (if using an "attachment" display)</li>
|
||||
<li> .attachment-after (if using an "attachment" display)</li>
|
||||
</ul>
|
||||
|
||||
So for example:
|
||||
<pre>
|
||||
div.view-myview div.view-header {
|
||||
/* make the header stand out */
|
||||
font-size: 120%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.view-myview div.view-footer {
|
||||
/* Make the footer less important */
|
||||
font-size: 80%;
|
||||
font-style: italic;
|
||||
color: #CCC;
|
||||
}
|
||||
</pre>
|
||||
|
||||
In the above example, we whimsically made the header bold and in a bigger font, and the footer smaller, italicized, and greyish.
|
||||
|
||||
<h3>Views with fields</h3>
|
||||
If your view has fields, each field is uniquely tagged with its ID. A field's ID may be gleaned from the Theme: Information page. Note that due to CSS rules, any _ in the id will be converted to - automatically, so if you have a field whose id is 'edit_node' (this is the field used to provide an "edit" link to a node), it will be 'edit-node'. Additionally, to make sure that the view IDs don't conflict with other css classes in the system, they will be pretended with 'views-field-'; thus, the final CSS class for the field with the id 'edit_node' will be <strong>views-field-edit-node</strong>.
|
||||
|
||||
Exactly how this appears is going to depend upon the style you're using. For example, the 'unformatted' style uses <strong>div.views-field-edit-node</strong> and <strong>div.views-label-edit-node</strong> to access that particular field, but a table would use <strong>td.views-field-edit-node</strong> and <strong>th.views-field-edit-node</strong> to access the table header; or just <strong>.views-field-edit-node</strong> to affect both.
|
||||
|
||||
<pre>
|
||||
.view-myview th {
|
||||
color: red; /* make all headers red */
|
||||
}
|
||||
|
||||
.view-myview .views-field-title {
|
||||
font-weight: bold; /* Make the 'title' field bold */
|
||||
}
|
||||
|
||||
.view-myview td.views-field-body {
|
||||
font-size: 60%; /* Make the text in the body field small */
|
||||
}
|
||||
</pre>
|
||||
|
2
modules/views/help/updating.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
TODO: This document needs to be fleshed out.
|
||||
|
50
modules/views/help/using-theme.html
Normal file
|
@ -0,0 +1,50 @@
|
|||
Views theme templates are straightforward to use with the Drupal theming system. If you are unfamiliar with the theming system at all, you should probably at least read <a href="http://drupal.org/node/173880">drupal.org theming documentation</a>. That said, these are the important things you need to know:
|
||||
|
||||
<ol>
|
||||
<li> Copy a base Views template to one of the names provided from the Theme: Information section of the View. Copy this template right into your theme directory. </li>
|
||||
<li> Clear the theme registry. See the <a href="http://drupal.org/node/173880#theme-registry">instructions</a> for how to do this. </li>
|
||||
<li> Your new template should now operate; assuming you picked a nicely named template that includes the view name, that template should now be active for your view. A good example is <strong>views-view-list--foobar.tpl.php</strong> which would work for a view named 'foobar'.</li>
|
||||
<li> You can now modify this template all you like.</li>
|
||||
</ol>
|
||||
|
||||
For any template that uses fields, the fields will be in array. In order to use this effectively, you will need to understand enough PHP to fetch data from an array. This is a place where the <a href="http://drupal.org/project/devel">devel module</a> can really help you, because you can use its dsm() function right in your template to see what variables it uses. There is an alternative to dsm() that works without devel module, but it's a bit longer to use.
|
||||
|
||||
For example, I placed the following code inside a loop in views-view-table.php.php:
|
||||
<code> <?php drupal_set_message('<pre>' . var_export($row, true) . '</pre>'); ?>
|
||||
</code>
|
||||
|
||||
And it produced this output:
|
||||
<code> array (
|
||||
'nid' => '97',
|
||||
'title' => 'Scisco Ideo Vicis Feugiat Qui',
|
||||
'name' => 'luwrepuslan',
|
||||
)
|
||||
</code>
|
||||
|
||||
My view had three fields:
|
||||
<code>Node: Nid
|
||||
Node: Title
|
||||
User: Name
|
||||
</code>
|
||||
|
||||
The contents of the $row variable included these fields, in precisely the order that I had arranged them to using the Views rearrange link. Also worth noting, though, is that each field also has an identifier so it can easily be pulled out of the row should I want to display it differently. Using
|
||||
<code><?php print $row['title']; ?>
|
||||
</code>
|
||||
|
||||
Would print just the title for that row. Please remember that I'm doing this inside the loop, so this will get repeated for every row of the view.
|
||||
|
||||
The IDs used to fetch items from the array, id <strong>$row['title']</strong> can be quickly and easily looked up on the Theme: Information page. Once a field has been added to the view, its ID will not change, but note that if there are two "title" fields in a view, one will be 'title' and the other will be 'title1', in order to prevent namespace collisions.
|
||||
|
||||
The important thing here is that Views does provide IDs. Views doesn't tell you what these IDs are, but it's easy to get them by dumping the row data and doing a simple visual inspection. Views does guarantee that these IDs will not change, unless you actually add a new field and remove the existing one (in which case 'title', above, would become 'title1').
|
||||
|
||||
<h2>The basic fields template</h2>
|
||||
|
||||
The most common template people will need to rewrite is the "simple" views-view-fields.tpl.php, which is the template used by the <i>Fields</i> row style and all it does is display a simple list of fields. However, it is not that simple to the user. Because the template can't inherently know what the fields are, it has to go through an array in a loop.
|
||||
|
||||
This loop isn't very handy when you really want to have fine control over the template by placing your fields precisely where and how you want. Relax, though; if you know what your fields are, you can rewrite this. If you end up writing your own HTML, the only part that is really important is the content for each field. We know from above that you can get the ID for each field on the Theme: Information page from the view. In the header for the template, we can see that the fields are all in the $fields array, and each field is an object. That leads us to this:
|
||||
|
||||
<code><?php print $fields['some_id']->content; ?></code>
|
||||
|
||||
Assuming you replace some_id with an id found on the theme: information page, this code will print the content for that field. You can also get the label and some other data about the field, as well as the raw information. Complete details for what is available are documented directly in views-view-fields.tpl.php.
|
||||
|
||||
Keep in mind that if you rewrite your templates using this, you'll need to maintain this template whenever changes are made to the fields of the view; while this isn't generally recommend, sometimes it's necessary to get the kind of control you might ultimately need.
|
21
modules/views/help/view-type.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<p>The <strong>view type</strong> describes how this view is stored; Views is capable of having Views entirely in code that are not in the database. This allows modules to easily ship with Views built in, and it allows you to create a module to store your views for easy deployment between development and production servers.</p>
|
||||
|
||||
<dl>
|
||||
<dt><strong>Normal</strong></dt>
|
||||
<dd>Normal views are stored in your database and are completely local to your system.</dd>
|
||||
|
||||
<dt><strong>Default</strong></dt>
|
||||
<dd>Default views are stored only in code and are not anywhere in your database. They may be <strong>enabled</strong> or <strong>disabled</strong> but you may not completely remove them from your system. You can <strong>override</strong> the view which will create a local copy of your view. If you do this, future updates to the version in code will not affect your view.</dd>
|
||||
|
||||
<dt><strong>Overridden</strong></dt>
|
||||
<dd>Overridden views are stored both in code and in the database; while overridden, the version that is in code is completely dormant. If you <strong>revert</strong> the view, the version in the database will be deleted, and the version that is in code will once again be used.</dd>
|
||||
</dl>
|
||||
|
||||
You may store your views in code with the following procedure:
|
||||
<ol>
|
||||
<li> Create a module to store the views. </li>
|
||||
<li> Add the function <em>MODULENAME_views_default_views()</em> to this module. </li>
|
||||
<li> Export the view you wish to store in your module in code. Cut and paste that into the abovenamed function. Make sure the last line of the view is: <em>$views[$view->name] = $view;</em></li>
|
||||
<li> Make sure the last line of the function is <em>return $views;</em></li>
|
||||
<li> After you make any changes, be sure to <strong>clear the Views' cache</strong>. You may do this from the <strong>Tools</strong> menu.</li>
|
||||
</ol>
|
203
modules/views/help/views.help.ini
Normal file
|
@ -0,0 +1,203 @@
|
|||
[advanced help settings]
|
||||
line break = TRUE
|
||||
|
||||
[about]
|
||||
title = "What is Views?"
|
||||
weight = -40
|
||||
|
||||
[getting-started]
|
||||
title = "Getting started"
|
||||
weight = -45
|
||||
|
||||
[example-users-by-role]
|
||||
title = "Create a page to list users by role"
|
||||
parent = getting-started
|
||||
weight = -10
|
||||
|
||||
[example-recent-stories]
|
||||
title = "Create a block of recent stories"
|
||||
parent = getting-started
|
||||
weight = 0
|
||||
|
||||
[example-user-feed]
|
||||
title = "Create an RSS feed of user posts"
|
||||
parent = getting-started
|
||||
weight = 30
|
||||
|
||||
[example-author-block]
|
||||
title = "Create a block of author's recent blog posts"
|
||||
parent = getting-started
|
||||
weight = 40
|
||||
|
||||
[view-type]
|
||||
title = "View types"
|
||||
|
||||
[display]
|
||||
title = "Displays"
|
||||
weight = -30
|
||||
|
||||
[display-default]
|
||||
title = "Default display"
|
||||
parent = display
|
||||
weight = -20
|
||||
|
||||
[display-page]
|
||||
title = "Page display"
|
||||
parent = display
|
||||
weight = -15
|
||||
|
||||
[display-block]
|
||||
title = "Block display"
|
||||
parent = display
|
||||
weight = -10
|
||||
|
||||
[display-attachment]
|
||||
title = "Attachment display"
|
||||
parent = display
|
||||
|
||||
[display-feed]
|
||||
title = "Feed display"
|
||||
parent = display
|
||||
|
||||
[argument]
|
||||
title = "Arguments"
|
||||
parent = about
|
||||
|
||||
[field]
|
||||
title = "Fields"
|
||||
parent = about
|
||||
|
||||
[sort]
|
||||
title = "Sorts"
|
||||
parent = about
|
||||
|
||||
[filter]
|
||||
title = "Filters"
|
||||
parent = about
|
||||
|
||||
[relationship]
|
||||
title = "Relationships"
|
||||
parent = about
|
||||
|
||||
[style]
|
||||
title = "Output styles (View styles)"
|
||||
weight = -20
|
||||
|
||||
[style-row]
|
||||
title = "View row styles"
|
||||
parent = style
|
||||
weight = 10
|
||||
|
||||
[style-list]
|
||||
title = "List output style"
|
||||
parent = style
|
||||
|
||||
[style-unformatted]
|
||||
title = "Unformatted output style"
|
||||
parent = style
|
||||
weight = -6
|
||||
|
||||
[style-table]
|
||||
title = "Table output style"
|
||||
parent = style
|
||||
weight = -5
|
||||
|
||||
[style-grid]
|
||||
title = "Grid output style"
|
||||
parent = style
|
||||
weight = -5
|
||||
|
||||
[style-rss]
|
||||
title = "RSS output style"
|
||||
parent = style
|
||||
weight = -5
|
||||
|
||||
[style-fields]
|
||||
title = "Fields row style"
|
||||
parent = style-row
|
||||
|
||||
[style-node]
|
||||
title = "Node row style"
|
||||
parent = style-row
|
||||
|
||||
[style-node-rss]
|
||||
title = "Node RSS item row style"
|
||||
parent = style-row
|
||||
|
||||
[style-comment-rss]
|
||||
title = "Comment RSS item row style"
|
||||
parent = style-row
|
||||
|
||||
[style-summary-unformatted]
|
||||
title = "Unformatted summary style"
|
||||
parent = "style"
|
||||
weight = 10
|
||||
|
||||
[style-summary]
|
||||
title = "List summary style"
|
||||
parent = "style"
|
||||
weight = 10
|
||||
|
||||
[menu]
|
||||
title = "Menu options (page display)"
|
||||
|
||||
[path]
|
||||
title = "Path options (page display)"
|
||||
|
||||
[analyze-theme]
|
||||
title = "Theme information"
|
||||
|
||||
[using-theme]
|
||||
title = "Using Views templates"
|
||||
parent = analyze-theme
|
||||
|
||||
[theme-css]
|
||||
title = "Using CSS with Views"
|
||||
parent = analyze-theme
|
||||
|
||||
[overrides]
|
||||
title = "What are overrides?"
|
||||
|
||||
[embed]
|
||||
title = "Embedding a view into other parts of your site"
|
||||
|
||||
[new]
|
||||
title = "What's new in Views 2"
|
||||
weight = -42
|
||||
|
||||
[updating]
|
||||
title = "Updating your views from Views 1 to Views 2"
|
||||
|
||||
; API related
|
||||
[api]
|
||||
title = "Views' API"
|
||||
weight = 100
|
||||
|
||||
[api-tables]
|
||||
title = "Describing tables to Views"
|
||||
weight = -100
|
||||
parent = api
|
||||
|
||||
[api-default-views]
|
||||
title = "Using default views in your module"
|
||||
weight = -90
|
||||
parent = api
|
||||
|
||||
[api-handlers]
|
||||
title = "How Views handlers work"
|
||||
weight = -50
|
||||
parent = api
|
||||
|
||||
[api-plugins]
|
||||
title = "How Views plugins work"
|
||||
weight = -40
|
||||
parent = api
|
||||
|
||||
[api-upgrading]
|
||||
title = "Upgrading your module Views 1 to Views 2"
|
||||
parent = api
|
||||
|
||||
[api-example]
|
||||
title = "Integrating the Node Example module"
|
||||
parent = api
|
||||
weight = 100
|