Views Configuration at Drupal Camp Toronto 2012
Upcoming SlideShare
Loading in...5
×
 

Views Configuration at Drupal Camp Toronto 2012

on

  • 2,096 views

So you know how to use Views, but feel like you're just scratching the surface. Views is a powerful module that allows you to build out complex functionality with just a few clicks of the mouse. This ...

So you know how to use Views, but feel like you're just scratching the surface. Views is a powerful module that allows you to build out complex functionality with just a few clicks of the mouse. This session will cover some of the more advanced features of the Views and take your knowledge of Views to the next level.

Topics include:
Changing the Results (adding more data, filtering options)
Contextual Filters (Arguments)
Relationships: Pulling in Related Data to Views
Formatting Views and Changing the Markup
Creating Administrative and Interactive Views
Extending Views with Other Modules

Statistics

Views

Total Views
2,096
Views on SlideShare
1,899
Embed Views
197

Actions

Likes
1
Downloads
23
Comments
0

7 Embeds 197

http://evolvingweb.ca 166
http://tweets.quevin.com 13
https://twitter.com 12
http://www.evolvingweb.ca 3
https://si0.twimg.com 1
http://www.mobilephoneemulator.com 1
http://localhost 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Get people to open their manuals, and check out the “before you start” activity. This is an activity for people who arrive early. It is optional. Whether they are familiar with this technique or not, it is useful. Wireframes can make it easier for participants to communicate their questions. Go around and try to get familiar with the kinds of projects students are interested in, find some commons threads you can bring up later. \n
  • Fill in information about your company!! Or ALT+TAB to your own site, or add in your own slides.\n
  • With these things, you can create\n
  • First frame the problem that Views was made to conquer. \n
  • This is an example of custom PHP development - combining queries, logic and display. You’d connect to your database, gather data, and then display it- in this case the HTML output is a table. Later if you wanted to change the query or change the output, you’d have to edit code like this.\n
  • Each time you make a new View you start with the wizard. Note: when you select Show content/users/taxonomy- that is the base table and you can’t change that later.\n
  • You can get most things done right from within the wizard. Note that the WIZARD disappears after your initial set up.\n
  • And when you want to access the advanced settings, there is the full UI. \n1. You can change for example, if content is listed in a TABLE or in a bulleted list. \n2. You can add filters, and change the default sort orders. \n3. You can specific what path it’s on and who can access it. \n4. You can relate content to other content by checking the context. \n
  • First you select the kind of information you want to query. Views can query Content, users, taxonomy and comments. This cannot be changed afterwards. Say for example, you want to query content. \n
  • You can then pull individual fields to display, instead of showing the whole record. Views can then be output in a number of formats. As an HTML list, or just showing two specific fields, as a sortable table, or as points on a map, using a mapping module to extend Views.\n
  • Content can be output in various ways. For example, as a page with a full path. Or as a block that can be placed in the layout. Or as an RSS feed, attachment, etc. We’ll see how to do this soon!\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • You can WAIT to do this part of the presentation until after you have demo’d the basic functionality. \n
  • This shows a list of author content showing on the user’s profile page.\nOther examples could be “show me a list of MY content in a block on the site”\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • You can WAIT to do this part of the presentation until after you have demo’d the basic functionality. \n
  • 1st - select the region field. formatted as plain text. \n2nd - rewrite the output so the two fields are in one row.\n3rd, this shows the out roughly. \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • At the bottom of the Views UI you see the query code output.\n
  • At the bottom of the Views UI you see the query code output.\n
  • Good things to know about Views!\n
  • Apply what you’ve learned to new situations.\nContinue to keep track of developments in the community.\nImprove your site building skills by becoming familiar with more popular modules.\nLook at popular Drupal websites to learn: How did they do that?\n

Views Configuration at Drupal Camp Toronto 2012 Views Configuration at Drupal Camp Toronto 2012 Presentation Transcript

  • VIEWSCONFIGURATION
  • About me • Drupal consulting, development, and training • Help organizations build@suzanne_kennedy awesome Drupalevolvingweb.ca websites with custom functionality
  • What Can You Do with Views?• Site Building Tools • Lists of content • A way to build pages and blocks • Related content blocks• Interactive Lists • Fancy lists (calendars, slideshows, maps) • User control of sorts/filters
  • Introduction to Views
  • Views: Query builder• <?php // Connecting, selecting database $link = mysql_connect(mysql_host, mysql_user, mysql_password) or die(Could not connect: . mysql_error()); echo Connected successfully; mysql_select_db(my_database) or die(Could not select database); // Performing SQL query $query = SELECT * FROM my_table; $result = mysql_query($query) or die(Query failed: . mysql_error()); • // Printing results in HTML // Printing results in HTML echo "<table>n"; echo "<table>n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "t<tr>n"; while ($line = mysql_fetch_array($result, foreach ($line as $col_value) { } MYSQL_ASSOC)) { echo "tt<td>$col_value</td>n"; echo "t</tr>n"; echo "t<tr>n"; } echo "</table>n"; foreach ($line as $col_value) { // Free resultset echo "tt<td>$col_value</td>n"; mysql_free_result($result); } // Closing connection mysql_close($link); echo "t</tr>n"; ?> } echo "</table>n";
  • Views Wizard Choose base table Change types Term filters Simple sort
  • Views Wizard Page or block Display settings Add to menu
  • Views Editor
  • Choose What to ListContent Users Taxonomy CommentsContent title D. Schrute adventure Wow, cant Germany city breakwait to get dwight city break 8 Sept visit. J. Halpert Spain sailing joe Me too! shopping 8 Sept
  • Choose a Format
  • Choose a Display Web Page Title http://example.com/city-guides Google Page display (banner)City guides Sign upBeppu nameFar far away, behind the word mountains, far from the countries Vokalia andConsonantia, there live the blind texts. Separated they live in Bookmarksgrove right atthe coast of the Semantics, a large language ocean. email Block display ButtonParisFar far away, behind the word mountains, far from the countries Vokalia andConsonantia, there live the blind texts. Separated they live in Bookmarksgrove right at City guides by topicthe coast of the Semantics, a large language ocean. Budget City breakMali FamilyFar far away, behind the word mountains, far from the countries Vokalia and LuxuryConsonantia, there live the blind texts. Separated they live in Bookmarksgrove right at Sun and seathe coast of the Semantics, a large language ocean.
  • CHANGING THERESULTS
  • Filtering Results
  • Filtering Criteria Choose a field to filter by
  • Operators for FiltersOperatorschangebased onthe fieldbeingused to filter
  • Operators for FiltersFilter toshow onlyusers whohave apicture.
  • Filtering by Date • Use the Date Views moduleFilter to onlyshowresults witha start datein the future
  • Contextual Filters
  • What are Contextual Filters?• Dynamic filters• Filter content based on the context of the view• Aka arguments Eddie Eddie likes to travel with his mandolin. Or sometimes the ukelele. In a pinch, hell travel with just his tambourine. By this contributor... Best in Beppu Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. Paris excursions Far far away, behind the word mountains, far from the countries Vokalia and
  • Where does the context come from?• The URL • node/24 • taxonomy/term/• Passed directly to the view • From Panels • In code• PHP Code • Add custom code snippet to determine what argument to pass to the view (Bad)
  • Where does the context come from?
  • Examples• Author Page: Show content by this author• Blog Post: Show blog posts in the same category• Any Node Page: Show fields from the current node
  • About the Author
  • Related Content
  • Contextual Filters for Content Panes
  • Views relationships
  • Views Relationships• Join a Views result to a related record, so you can show fields from that record
  • Add Relationship to an Instructor Node Course InstructorCourse Title NameDepartment Field Specialty FieldCourse No. Field Entity ReferenceInstructor Field
  • Adding a Relationship
  • Add Relationship to an Instructor Node
  • Inverse Relationships with Entity Reference• Course->Instructor: Create a relationship from your result to the referenced content• Instructor->Course Create an inverse relationship from the referenced content to the referencing content
  • Other Use Cases• Blog posts: Info about the author of a node• Admin view of nodes: Link to translations• Events calendar: Info about room location
  • Relationships + Contextual Filters Examples• Blog Post: Show the other blog posts by the post’s author• Course Page: Show other courses by the course’s instructor
  • Listing more stuffwith Views
  • Choose what Views shows Choose base table Change types Term filters Simple sort
  • What else can you show with Views?• Aggregator items• Solr search results• Content Revisions• Products• Media• Webform Submissions• Files
  • Apache Solr• Apache Solr Views Integration module
  • Webform Submissions
  • Aggregator items
  • Your Custom Data• hook_views_data• Tell Views about the custom data that you’ve added with your module• http://evolvingweb.ca/story/developing- views-part-i-describing-your-data-views
  • Your Custom Data
  • CHANGING THEMARKUP
  • Views Formats
  • Built-in Formats• Table• Unformatted List• HTML List• Jump List• Grid
  • Views stylesUnformatted list - Teasers
  • Views styles Unformatted list - Fields TitleTrimmed body Thumbnail image
  • Views styles Table
  • Views styles HTML list
  • Extending Views Formats• Views Slideshow• Views Accordion• Calendar• Map (GMap, Open Layers, Leaflet modules)
  • Configuring Views Styles
  • Views Slideshow
  • Views Slideshow Config
  • Views Accordion
  • Calendar
  • Building a Calendar• Calendar provides a views template
  • Calendar Config
  • Map View
  • Altering Field Output
  • Altering Field Output
  • Altering Field Output
  • Altering Field Output
  • Theming ViewsOutput
  • Theme Information
  • Theme Information
  • Theme preprocess functions for Viewsmytheme_preprocess_views_view(&$vars) - generic for all viewsmytheme_process_views_view(&$vars) - generic for all viewsmytheme_preprocess_views_view_list(&$vars) - generic for List style viewsmytheme_preprocess_views_view_field(&$vars) - generic for each field
  • INTERACTIVE VIEWS
  • Giving Users Control
  • Allowing users to filter content
  • Modules for Filtering• Better Exposed Filters • Provides more options for exposed filters• Views Dependent Filters • Exposed filters that show up when a particular option is selected
  • Exposed Sorts• Use a table view and expose sorts to users
  • Exposing Search• Provide a ‘keywords’ exposed filter
  • Ajax-enabled Views• Add Ajax for pagers, filters
  • Extending Views:Administrative Views
  • Administrative Views Modules• Administrative Views• Draggable Views• Views Bulk Operations
  • Administrative Views
  • Draggable Views
  • Draggable Views
  • Views Bulk Operations
  • More Views Features
  • Previewing Output
  • Viewing the Query
  • Views in CodeExport ViewsAdd Views to Your Features
  • Q+A