In this second section of the guide, you will be introduced to the powerful Views module.
You will create an Articles View, which will be used to show a full page listing of all the Article content you've created (the /articles page referred to in the preceding section), as well as a smaller listing of the latest Articles in the form of a Block, which you can include in the sidebar of your site, on your home page, or anywhere else you can imagine.
After completing this section of the guide you will have gained experience working with the Views 2 module for Drupal 6, and will be able to apply the knowledge you gain towards creating custom Views for a nearly unlimited number of purposes on your site. Once you have learned to use both CCK and Views, your outlook on developing websites will never be the same.
The next step is to set up a new View using Views module, to generate a list of the latest Articles, making use of the fields that were set up in the Article content type. Of course, Views module can export/import Views, but going through the full process below will help you learn how Views works so you will be able to work with it and create your own custom Views.
articles. Optionally add a short View description for your own reference, and a View tag of article to help you find the View in the future. Leave View type set to Node. Press "Next" to continue.Views version 2 now offers the ability to define multiple "Displays" for a single View, each of which can present the same View in a different way.
The first thing to do when creating a new View is to set up the Defaults configuration. The options you set for Defaults apply to all other custom Displays you create later. However, all of the options set for Defaults can be overridden with your own custom settings by each Display. This saves you time by defining some or all of the settings that will be shared by every Display.
Articles. Press the "Update" button to save the new setting.Full pager option, and press the "Update" button.Content: Text: Article Teaser (field_article_teaser_text)Node: Post dateNode: TitleNone.Custom and enter the Custom date format as F jS, Y.Link this field to its node option.Node: Post date item. In the following screen choose Descending for the Sort order and press the "Update" button.Node: PublishedNode: TypePublished (which ensures only content that is marked as Published will be shown).Article under "Node type".You will be creating two custom Displays: the first, a "Page" Display, which will be a full-size listing of the articles, and a second "Block" Display, which will be a small sub-listing of article teasers which will be placed in the sidebar of the site (or on your home page). So let's begin first with the "Page" Display:
Page, click on the "Add Display" button. A new tab with the name "Page" will appear below the Default Display.Page: Articles. Press the "Update" button, and then press the "Save" button at the bottom of the Views interface to save the View - you should now see that the Page Display is now named Page: Articles (Display name changes aren't updated until you save the View). Click on the new Page: Articles tab to make it the active tab again.articles if you want the URL to be example.com/articles). Press the "Update" button.Normal menu entry option, enter the menu item title in the field (e.g. Articles), and press the "Update" button. Menu items generated by Views modules appear by default in Drupal's Navigation menu. You can adjust this (e.g. to move it to your Primary Links menu) though you MUST first save your View before navigating away from it. Go to Administer > Site building > Menus > Navigation (admin/build/menu-customize/navigation), locate the name of your menu item, click edit, and choose the Primary links menu under the "Parent item" option.Now you'll create the second Display, this time as a "Block" type, which will be a small sub-listing of article teasers which will be placed in the sidebar of the site (or on your home page):
Block, and click on the "Add Display" button. A new tab with the name "Block" will appear below the Default and Page: Articles Displays.Block: Articles. Press the "Update" button, and then press the "Save" button at the bottom of the Views interface to save the View. Click on the new Block: Articles tab to make it the active tab again.Create more link, and press the "Update" button.
Note: Since the "More link" option only applies to Block Displays, you could turn this setting on in the Defaults Display - however it's included in this way here as at least one example of using the Override feature of Views Displays. You can use this feature to do all kinds of interesting things within a single View, including adding specific fields, filters, and arguments to one Display of the View, and completely different ones to a different Display (thereby creating a separate Display that is based on the same underlying Default values, but otherwise an entirely different View).
The View and its Displays are now complete. However, you can return to edit and adjust the View at any time.
Ensure that you click the "Save" button for the View (make sure you see the "The view has been saved" message at the top of the screen). Pay a visit to http://www.example.com/articles to see the output of the Page: Articles Display you've created.
When you're ready proceed to the next section of the guide, where you will activate the Block: Articles Display to be used in the sidebar of your site.
The Block: Articles Display you just created has now become automatically available to the rest of Drupal as a "Block" at Administer > Site building > Blocks (admin/build/block).
Right sidebar). The articles block will immediately move out of the Disabled category and up into the Right sidebar category higher up on the page. You can adjust its position relative to the other blocks in that Region using the move icon at the far left.More info to add...
- You are not limited to only the blocks that are pre-defined for your theme.
- Short mention of the possibility of adding blocks to your front page (and link to article on making front pages).