Tutorial Drupal Views: How to create a view

ui drupal views

Drupal Views: guide and notes
The Views module allows webmasters to drupal to create, manage and display lists of content and therefore a way of presenting the contents and tables. Essentially it is a query builder that, given some information, it can create queries, execute and lead to visual data in pages, blocks or other formats. Every single view can also have multiple views.
But let the action by installing the module in the usual folder sites / all / modules and enabling in Directors / modules checkmarks on Views - Views UI (User Interface that enables to change views) Views and Exporter (useful for exporting the code a view already created and import it into another site).
In Directors / Construction Site, click on Views (Views or in English if our copy of Drupal) and login to a list where we can find some views already ready, some filled in automatically from other modules we have installed, others already present in the core of Views same. We also note that some of them are disablitate. Next to each view we have a few options:
  • Edit, to enter into the very heart of views which explain shortly,
  • Export, which is the option we have enabled the forms to export and import the view elsewhere,
  • Clone, to clone useful precisely the view and give it a new name without affecting the previous and finally
  • Delete, which is self-explanatory.
The views already present are a great exercise to extricate the views and some are also very useful for purposes ke we shall see later, when we have acquired more knowledge on the form. Top Tools that are used to set some general settings, Import joining the function described above with the exporter, Add creates a new view from scratch, List go back to where we are now.
Let's start with Tools:

TOOLS (Advanced Stage):

The first entry enables a special string in the Where clause (we refer to the db) and is useful to take the easy track query in the db. It is used only in case of problems and we cmq in a more advanced stage.
The second item jumps can be cached view data and can have a strong impact on the performance of the site.
The third is used to disable the notification noisa install the Advanced Help (this guide there, no?)
The fourth is to show a preview of the work we do with the views at the top or bottom of the view. Let it down.
The fifth shows the execution of other queries merntre is in place rendering the view in the preview.
The sixth only serves to eliminate the effect hover on links.
The seventh enable performance statistics if Devel module is enabled.
The ottavadisabilita javascripts if it creates problems with views.
The next customize in what region of the theme see statistics
The last select the field as any to be displayed.
Finally top it all is a button to clear the cache of all views.
We click on add and here begins the construction of our view, establishing first a view name (lowercase and underscores), then enter a description for the view that we are building and a category (it's just a way to facilitate the search view in the admin panel).
In the View Type (Type of view) we can choose among various options. The decision affects the arguments, the fields filters and sorting criteria that we will find in the construction of the view. To get everything possible we use node (the choice can not be changed!)
We create a type of node view and then we go Next, to achieve this, which at first glance may discourage many of you or cmq appear confusing. But it is only a matter of time, because you will discover with the use, as is well-organized user interface to work.


ui views drupal module


Let's start with the leftmost column that contains all kinds of possible views for our view (expandable with other modules ... think of the panel ...).
The types of display will tell views where the data. Each view PUA have their own settings, but when it is created, a view takes all its basic settings from the default display which all views, and must play. Default display plays a key role because the general settings for all kinds of views that we are going to create Any change to the settings of a view (if you do not use the override function) is set to change all the settings of the other views. Let's see one by one kind of view that we can create:
Default: The default display retains the settings common to all other views. Then you edit a parameter here and it will be changed to any other.
Page: create a real page with a path (route) a link to the menu (if any).
The pages take their arguments from the URL: you can insert topics using%
Block: a real prorio block that are found in the relevant section blocks can be positioned in any part of the theme.
The blocks do not accept arguments, the argument will be that the default display
Feed: Allows you to attach an rss feed to a view
Attachment: This type of display is attached to another view in the same view. When the view is visited, the display attachment is made visible above, below, or above and below the main display. Attachments are useful eg to display a view with argument together with a summary page that accepts arguments and create a sort of glossary.
Once the ggiunta visualizzaizone preferred, pasiamo to second column


Name: modify the name of the view in the left column, so it's just a way of reminding us of what this show compared to the other that we will create.
Title: This is the title of the show when we go to visit her. Leaving No we do not have any title.
Style: The styles are the way in which data will be displayed in our view. In other words, a style is a template through which data will be displayed. All styles can be freely overwritten with custom templates placed in the root directory of your theme (see "Theming views")
By default we have "unformatted", Html ordered list or not, grill where we can customize the columns in number and position (horizontal and vertical). Finally table (the most powerful) that allows many configuration options (explain)
  • No formatting is very simple: the fields are displayed one after the other enclosed in a <div> so that it can be easily customized by manipulating the CSS vision
  • Grid: style grid displays each line of sight inside a grid, is customizable to decide how many columns must have (for a maximum of 4) and in which order allineae the lines (horizontal or vertical)
  • RSS output style: make it available only to choose the display type "Feed". Therefore, it will display the view as an RSS feed, which is used primarily for visualizzarlas as XML. This result will not be visible aglli users but can be used with the aggregator.
  • Table: Style table, each row in the table corresponds to a row in the result of the view. In the options of the table each field of view is presented with some additional information: Column: By default each field is placed in a column. However, we can place multiple fields in the same column. To do this you choose the field to represent the column, take another field and set the value in column choosing the field that represents the column. So we can do for the other fields to be placed in the spread column, but only the first field will be ordered. Separator: if there are more fields in the same column, you can insert a separator between a field and another. For example, |, or a comma or a bullet. No but if there are other fields in the column, the separator will not be displayed. Sortable: If selected, the column header will be ordered. You can assign a default sort order of default assigned to a column (either ascending or descending). HTML List: then an ordered list or not
Row Style: This item row style is what will be displayed in a view. Let me explain, we can choose the style node and therefore'll display one node per line, fields then display it in the fields selected in the row. We have different kinds of styles line:
Comment RSS item row style, this style line is available only if you have chosen the style RSS feed available when creating a View Feed. This style creates the necessary XML for an RSS feed for comments;
Style row fields, which displays each field defined in the view, one after the other. By default each field is added to a <div> unless it is selected in the options of the style line fields (by clicking the gear you access the options) you choose the alignment of fields and therefore will be included in a <span >. Two objects in a <div> will be displayed one after the top, the second in the first, two objects in a <span> will be displayed side by side on the same line. E 'can also insert a separator between the fields that can be written in html anke (eg. To have a space)
Node RSS row style item only available for the style and RSS creates the necessary XML for an RSS feed for the field of the node.
Node row style displays each object of sight through the function node_view (). You can not have a great control (customization) with this kind of view, but it can be done through the mechanism of customizing the theme of sight (usually node.tpl.php and its variants) in the theme information. Views adds node-view-VIEWNAME.tpl.php useful for customizing only the specific view and differentiate it from all others. This type of style does not use the fields, and then the section fields will be disabled. Finally, this type of style produces a large amount of queries and therefore may have a negative influence on performance.
Also this section is incremented by other modules. Note that in almost all the parameters k and we are going to change is a link that causes it to override that parameter is used only by the display that will not take rather than the default and therefore does not affect the other type of display (because any changes left in the default affects all other views.
Follow another series of options that do not require a real explanation anke because they depend on the tastes and needs of the user. Eg
Use Ajax choose whether to use ajax and then if the page is not reloaded;
In display items put a limit to the results that will give us the view (eg. 10) and then we enable the paginature so as to consult the results sfongliandone the pagine.Si can llimitare access to view to a role or to the role that has a special permit, you can write information nell'intrestazioni or in the bottom of the view or write directly in php etc..
Theme information, change the theme of sight. Refer to the last chapter of the guide.


The next column differs according to the type of view and shows a choice of insert administrative information, such as title that must have for example the block, a link to that view, etc.. Worth specifying only a couple of options.
· Options menu: From here you can create a link to view within a menu. For a simple link just select normal menu item and enter the name of the link and a menu that should be visible; investment menu tab is much more complex:
o All cards must have a parent, which is the highest hierarchical level. If, for example the path of sight is as / sheet for the parent to be 'example'
o All cards must have one default tab
o If the parent does not exist, when you create the default tab, views allow you to create
or Drupal only supports 2 levels of tabs.
For example, if we have 2 or views that you want to display as tabs we have:
§ In the first set the view path 'schede/scheda1'. Set it as the default tab, set the title to card1 and weight 0;
§ Click update and you will be sent a form to insert the parent. As long as it exists nn, select menu item and set the normal title cards.
§ The second view set the path tabs/tab2, set it as the menu card and put as title Tab2. Done what we have in the Navigation menu (or whatever you choose in menu item normal) with a link called cards, when we click we have the two cards created with card1 that appears first by default. (Nb a similar result it is possible to obtain it with the use module quick tabs, which in addition to the views as in this case, allows to put into tabs anke knots, or block and another).
· Options path: some viewing modes require a path (such as page and feed) which means that it can be received directly by calling a url as the primary class of a page of your site. An object after the path will be passed to the view as an argument. For example, if the path is foo / bar and the user visits www example com/foo/bar/baz/beta baz and beta will be given as arguments to the view that can be configured in the appropriate section. Anke can set a path to represent the topics that are in the middle. For esnode /% / someview.


A view can be easily visualized in other parts of the site: the easiest way is to use the function views_embed_view ():
/ **
* We put a sight with PHP.
* 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 does not 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.
* /
views_embed_view function ($ name, $ display_id = 'default') {
For example, create a page and after insrito this code we use the input format "php filter" (enable it in the modules), same thing with blocks: we create a new block, insert the code and use the php filter and then enter the bllocco where we want attraverdo section blocks that will allow us to place it in an area of ​​the theme or even calling.
Another method is the use of the module insert views that allows the insertion of views within a body field or body in a content type.
VIEWS OF EXAMPLE: practical applications
If we use the row style fields will be very limited in the choice of the same if we have not installed the cck, as we can only manage title and body. Through cck we can create a multitude of fields all be called in a view and then create increasingly complex plots (create separate guide)
RELATED MODULES (Expanding Views)



Similar Content

Study and monitoring of the SERP with Advanced Web Ranking

advance serp ranking

Companies are increasingly aware of the importance of the Internet to promote their business and more and more evident that the mere creation of a corporate website is not enough: you need to define an online identity of its products and to make sure that they are visible to network users.