380 likes | 391 Views
Wrapping Views around your fingers. Dennis Solis. Solis Media Group Over 20 years of application software development. 2 years of Drupal development Assisting with D8 Migration in core d.o . : densolis irc : # drupal-florida & # drupal -migrate: densolis skype: densolis.aol.com. 2.
E N D
Dennis Solis Solis Media Group Over 20 years of application software development. 2 years of Drupal development Assisting with D8 Migration in core d.o. : densolis irc: #drupal-florida & # drupal-migrate: densolis skype: densolis.aol.com 2
Views TopicsModules Contextual Filter views, ctools Relationshipentity entity reference entity connect Views Relationship views, ctools
Views If Time TopicsModules Views conditional views_conditional Download views_data_export
You are all experts in Contextual filters Relationships
What is a contextual filter? Basically a contextual filter is simply a way of limiting what information you displayed to the user.
Why? Help your users focus on items for which they are search. Limit what data the user see.
How could you possible be a CONTEXTUAL FILTER expert?
Contextual Filter Examples Courses on a restaurant’s menu Bad Camp sessions Airline reservations Filter by product types on Amazon or E-Bay
Contextual FiltersSamples • Restaurant Menu (Example 1) • Menu at a glance – show everything • Starters • Signature Appetizers • Main Entrees • Jack Daniel’s Grill • Sour and Salads
Contextual Filters Let’s examine the restaurant’s contextual filter (Example 2)
How could you possible be a RELATIONSHIP expert?
Relationships Because of the relationship, you know some things about the other person.
What is a relationships? Content User Author’s Name Content type (taxonomy) Image • Menu category • Starters • Appetizers
Why? You want to maintain a single copy / instance of your data. Your web site reference the single copy / instance of your data. If you change the data, it is changed through out the web site.
Relationships Author / user create a content node An image is associated with a content node A taxonomy term associated with a content node Another entity associated with a content node
How do you create arelationship? Kind of like setting up a taxonomy entry. Remember, an entity references another entity! Setup a content type of Waiter / staff Setup a content type of menu dish On the Customer Order, we will “connect” the customer order to both the Waiter / staff and menu dish content types.
Relationships (Example 3 & 4) CT - Menu section CT – Staff
Relationships (Example 5) CT – Dishes CT - Menu section CT – Staff
Relationships (Example 6) CT – Customer Order CT – Dishes CT - Menu section CT – Staff
Relationships (Example 7) CT – Customer Survey CT – Customer Order CT – Menu Item CT - Menu section CT – Wait staff
Univ. of Hard Knocks Suggestions for Views • Include node type in field name • Easily find field in views list of fields.
Relationship Examples • Display an customer order (Example 8) • Restaurant customer order relationships: • Waiter / staff • Item order reference menu dish
Relationship / SQL View • INNER JOIN: • Returns all rows when there is at least one match in BOTH tables. • Require relationship = Y • LEFT JOIN: • Return all rows from the left table, and the matched rows from the right table. • Require relationship = N
ViewsAdd relationships • Views – Add relationship (Example 8) • Referenced – Read entity referenced from source • View is based upon Customer Order and reading Staff, and Dish information • Referencing – Read source from entity reference • View is based upon Staff and reading Customer Order information.
Download a table into a CSV file modules: views_data_export The module view data export will allow you to download your table view into a comma separated value (CSV) file.
Download a table into a CSV file (Example 9) Data export is exposed on your view
Download a table into a CSV file (Example 10) Choose “Data Export” from the +Add in views Notice your Format is CSV File
Download a table into a CSV file • You can put replacement patterns in the file name • Setting • The text “by deselection this, the xml file…” is a bit misleading. • Need to check “Provide as file” if you want a download file!
Download a table into a CSV file • Make sure you specify: • A path • I used <view_path>_dnld • Attach to – The view to attach the download. • Batch export – Yes if big download • Pager = Display all items
Views conditionals module: views_conditional You want to check some condition before you decided to the field should be displayed. In my case, I check a person’s role before decide if they have the permissions to see a specific field. Example
UHK Suggestions for Views • Name content types in singular • Names views in plural • If using multiple views: • “All displays” vs “this page” • Structure -> Views -> Settings • Show the SQL query • Make input required BEFORE views runs.
UHK Suggestions for Views • Page views with same path. • Bad – only one view will appear in the menu • Good – if the different views have different role permission, you can have multiple views under one menu item – and role appropriate view will appear. • With views aggregation – do not sort the data. Let the aggregation do it. • Don’t forget to put in No Results message in your view.
Congratulation! You are now an Advance Views builder!