How to Use the Views UI and Theme a "View"

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    How to Use the Views UI and Theme a "View" - Presentation Transcript

    1. How to Use the Views UI and Theme a “View” Presented by Squiggy Rubio Oct. 17 th 2009
    2. Drupal is used a lot as a content management system Lets see what it offers out of the box...
    3.  
    4. Finding and managing content is hidden in the Administer menu It has one filter to sort through all nodes This may be fine for smaller sites, but what about sites with thousands of nodes?
    5. What is needed is a dashbord to control and present content
    6. Source: http://www.funny-potato.com/cockpits-pictures.html
    7. Just kidding!
    8. What you need is Views
    9. What is Views?
      • Creates custom lists of content
      • Provides many options for what content to display and how to present it
        • Lets you do all this without writing any (or very much) code
        • As of Views 2, almost any piece of information in your Drupal site can be accessed by the Views module
      • Views is a contrib module created and maintained by Earl Miles
    10. Who is Views for? Anyone who wants to speed up creating a site that requires special lists of content, not already available in Drupal core Anyone who is familiar with setting up and configuring a Drupal site and extending it with contributed modules
    11. Structure of a “view” Source: Found in the documentation of the Advanced Help module ( http://drupal.org/project/advanced_help )
    12. View “Style” You can wrap your rows in a table, grid, list, or unformatted divs
    13. Row styles can be nodes or fields
    14. Row style: Nodes
      • Can display the full node or the teaser
      • Markup is handled in node templates
      • Doesn't require theming views fields (phew!)
    15. Row style: Fields Title: Some interesting title Date: October 18, 2009 Type: Photo Title: Another interesting title Date: October 18, 2009 Type: Video
    16. Options that affect theming
      • Basic settings
        • Style: selects markup to wrap rows in, such as 'unformatted', table, HTML List, or Grid
        • Row style: selects either nodes or fields
        • Pager
        • Items to display
        • Header and/or footer input
        • More link
      • Fields (not available if row style is set to nodes)
    17. Setup one view, then create many variations with “displays”
      • Display types:
      • Page : gives the display a path so that the view is a self contained page
      • Pane : lets you embed your view in a Panel page (requires the Panels module)
      • Block : lets you embed your view into any block region or Panels layout
      • Attachment
      • Feed
    18. Theming a “View”
      • Views markup and classes accounts for most theming needs
      • If you want to change the markup in a view, Views provides a handy theming wizard in the Views UI
    19.  
      • Provides a list of template suggestions.
      • Available template names will apply theming to various levels of your view, from broad to more specific.
      • For example, you can select views-view—list.php and that will let you define the markup for all views that wrap their rows in a list. Or select views-view-list--media-listings--block-1.tpl.php and that will apply to just the current block display.
    20. Default templates in Views views-view.tpl.php views-view-unformatted.tpl.php views-view-list.tpl.php views-view-fields.tpl.php views-view-field.tpl.php Note: the Advanced Help module has excellent documentation with what each of these templates applies to. I will focus on the views-view-fields.tpl.php.
    21. Inside views-view-fields.tpl.php Contains a lot of logic, like foreach loops, etc) This is confusing if one doesn't know a lot of PHP
    22. This logic provides a general way to formate fields generated from the Views UI. However, it's not always needed for every view. If you're certain the fields you're view uses will not change frequently (or you don't mind updating your template file), you can replace this logic and default markup with your own markup. Then pull the individual fields into your markup.
    23. Syntax for views-view-fields.tpl.php Fields are the most common views element that need to be themed. The fields are stored in $fields, which is an array of field objects. Use this syntax to pull the fields out of the array to arrange them in your custom markup: <?php print $fields['title']->content; ?> The 'title' above is the name of your field. You can find the field names the Views UI.
    24. Some excellent Views resources Views project page http://drupal.org/project/views Advanced Help module (has excellent documentation, including a very good section on Views theming) http://drupal.org/project/advanced_help Views 2 theming (on drupal.org) http://drupal.org/node/352970 Views Developers (on groups.drupal.org) http://groups.drupal.org/views-developers
    SlideShare Zeitgeist 2009

    + Squiggy RubioSquiggy Rubio Nominate

    custom

    109 views, 0 favs, 0 embeds more stats

    Views is a popular Drupal contrib module that speed more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 109
      • 109 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 1
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories