Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Drupal 5 Views Recipes

You're reading from   Drupal 5 Views Recipes 94 recipes to develop custom content displays for your Drupal web site

Arrow left icon
Product type Paperback
Published in May 2009
Publisher Packt
ISBN-13 9781847196965
Length 412 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Toc

Table of Contents (22) Chapters Close

Drupal 5 Views Recipes
Credits
About the Author
Acknowledgement
About the Reviewer
Preface
1. Introduction to Views FREE CHAPTER 2. Working with Default Views 3. CCK and Views 4. Dates and Calendars 5. Views and Tools for Administrators 6. Views Galore 7. Theming and Layout 8. Navigating the Online Drupal Community Default Views in Drupal 5 Modules
Formatters
Style Plugins
Views Hooks for Coders
Modules Included in Recipe Ingredients
Additional Resources and Modules Mentioned in Recipes
Selected Noteworthy Patches to Views
Index

Recipe 1: Installing the Views module


Note

Ingredients *

Drupal 5: http://drupal.org

Host login access

Views: http://drupal.org/project/views

Views UI: contained within the Views module

*These ingredients are prerequisite for all of the recipes that follow, and will not be listed in subsequent ingredient lists.

The Views module has a straightforward installation, much like other Drupal module installs. The following recipe instructions incorporate a mix of Windows tools and the command line for locating files, creating directories, downloading files, and unzipping them. Consider following the recipe, but feel free to substitute file management approaches specific to your operating system and preferences. This recipe is followed by a page listing helpful command line shortcuts that you should incorporate into your practice if they are available on your host.

Finding or creating the <DRUPALROOT>/sites/all/modules directory

  1. Log in to your web server. You will need to know your host name, login name, and password.

  2. Locate the Drupal root directory on your server (a common directory location is /home/your_account/public_html).

  3. If this is the first contributed module in a brand new Drupal installation, you will need to create the modules subdirectory.

    • From your Drupal root directory, type the following to change into the <DRUPALROOT>/sites/all directory:

      cd sites/all
      
    • Make a new modules directory:

      mkdir modules
      
    • While you're there, you may as well create the theme directory, if it is not there already. We will use this directory in Chapter 7, Techniques for Theming Views

      mkdir themes
      
    • Now change to the modules directory:

      cd modules
      

Downloading and uncompressing the module

  1. Open the browser of your choice.

    Note

    Most of the screenshots in this book use the Firefox browser—a popular choice for many developers. Recipe 8 covers Firefox installation.

    Go to http://drupal.org/project/views, and read the page. There are several different versions of Views available for download. We are looking for the Download link marked Recommended for 5.x.

  2. Download the module from the Views project web page. Here is one way to do that:

    • Right-click in Firefox on Download.

    • Select Copy Link Location (in Internet Explorer, this link will be called Copy Shortcut). You now have text similar to the following in your clipboard:

      http://ftp.drupal.org/files/projects/views-5.x-1.6.tar.gz

      A file with the .tar.gz extension is affectionately known as a "tarball", reflecting the days when files were backed up onto tape archives.

    • Switch to your Drupal server window. Be sure you are still in your <DRUPALROOT>/sites/all/modules directory.

    • Type:

      wget <Paste><Enter>

      Note

      In many shell environments, you can use the right mouse button to paste text from the clipboard. In Windows, you can use Ctrl+V.

    • The result on your screen, after pasting the download link, will be:

      wget http://ftp.drupal.org/files/projects/views-5.x-1.6.tar.gz
      

    After pressing Enter, the download begins. You are provided with a status report of the percent complete as shown in the following screenshot:

  3. Uncompress the module to the <DRUPALROOT>/sites/all/modules/views directory. Enter:

    tar xvf views-5.x-1.5.tar.gz
    

    Depending on your system setup, you may need syntax such as this:

    tar -zxvf views-5.x-1.5.tar.gz
    

    You may also use an alternative uncompression tool, such as 7-Zip or WinRAR. WinRAR offers a graphical interface in Windows, but is also available with a command line interface for Mac and Linux systems. The output of the tar xvf views-5.x-1.5.tar.gz command is seen in the following screenshot:

Enabling the module

  1. Return to your browser window. Go to the Module page at: http://YOURSITE.com/admin/build/modules.

    If you are not already logged into your Drupal site as an administrator, you will need to do so. Scroll down to the Views fieldset and enable the Views and the Views UI modules by clicking the two associated checkboxes.

  2. Click on the Save configuration button.

    Congratulations! You will now see a message (similar to the screenshot that follows), signaling the successful installation of our module.

Recipe notes

UI is an abbreviation for "User Interface". The Views UI module offers a point-and-click approach for selecting content and output types, controlling view sort order, and so on. The Views UI can even generate a views programming code for you, as we'll see in Chapter 2. If the Views UI module were not enabled, you could still see the existing views and create new views through code. However, the Views UI module is quite helpful: even "Ninja" Drupal programmers will typically enable it.

Command line tips

These shortcuts will assist you in your Drupal development (your host environment may, or may not, have all of these shortcuts enabled).

  • Press Ctrl+U in the command line to clear everything to the left of the cursor. For instance, if you paste something, and then realize the wrong text was in the clipboard, it may be easier to clear the whole line than to press backspace many times.

  • Press Ctrl+K on the command line to clear everything to the right of the cursor.

  • Press the up arrow to re-use a previous command line. You may also search your command history with Ctrl+R.

  • Type !$ on the command line to reuse the last argument of the previous command line. For example:

    more views_ui.module views.module
    

    lets you page through the text of both modules. The last argument of that command was views.module. If your next command is:

    less !$
    

    this will print as:

    less views.module
    

    (This tip is difficult to find with a search engine. A Google search for !$ yields nothing.) Quit both the more and less commands by typing:

    Q
    
  • Use "man" pages. Man is shorthand for the manual.

    man less
    

    reveals that

    Less is a program similar to more but which allows backward movement in the file as well as forward movement.

  • Type cd to go to your home directory.

    To return to the previous directory you were in, type:

    cd -
    
  • If you are not sure where you are in your directory structure, type:

    pwd
    

    This is the "print working directory" command, which provides the full path to your current directory. This is especially useful if your prompt is not set up to already display the full path.

  • Use the Tab key for command line completion. In step 6 of the recipe above, you could type:

    tar xvf v<tab>
    

    If there is only one file that begins with v in the directory, the Tab key will conveniently complete the full name of the zipped .tar file:

    tar xvf views-5.x-1.5.tar.gz
    

    Press Enter to run the command.

    If you already had the votingapi module installed, for instance, you would need to enter:

    tar xvf vo<tab>
    

    to distinguish voting from views.

You have been reading a chapter from
Drupal 5 Views Recipes
Published in: May 2009
Publisher: Packt
ISBN-13: 9781847196965
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image