views examples using arguments and
play

Views Examples: Using Arguments and Relationships April 19, 2010 - PowerPoint PPT Presentation

Views Examples: Using Arguments and Relationships April 19, 2010 Michelle Lauer Drupal.org: miche Twitter: @bymiche Blog: developedbymiche.com/downloads CP: commonplaces.com/resources CommonPlaces.com Development Co-development & Mentoring


  1. Create View: Glossary 6. Block Display – Add Arguments 58

  2. Create View: Glossary 6. Block Display – Configure Arguments – Node: Title 59

  3. Create View: Glossary 6. Block Display – Configure Arguments – Node: Title 60

  4. Create View: Glossary 6. Block Display – Preview 61

  5. Create View: Glossary 1. Filters • Node: Published = Yes • Node: Type = Is one of Glossary Item 2. Fields • Node: Title • Content: Body 3. Sort Criteria • Node: Title asc 4. Page: Landing • Path = glossary • Group By = Node: Title (length of 1) 5. Page: By Letter • Path = glossary/% • Arguments = Glossary Mode 6. Block: Letters • Arguments = Summary Sorted 62

  6. View: Glossary mysite.com/glossary 63

  7. View: Glossary mysite.com/glossary/b 64

  8. View: Glossary mysite.com/glossary/b/blue 65

  9. Create View: Glossary Arguments – What did we just do? Page: Landing • Added a field of Node: Title • Used only the first letter • Exclude from display • Display settings -> Group by Node: Title • Path = glossary Block Page: By Letter • Added argument of Node: Title • Added argument of Node: Title • Used only the first letter • Used only the first letter • Summary Sorted if no argument • Hide page if no argument • Basic Validation (just text) • Basic Validation (just text) • Path = glossary/% 66

  10. Example 2 Side Content 67

  11. Example: Side Content Our goal is to show specific related content in the sidebar for specific nodes. The content editor should be able to create as much content as they want and assign the page it should appear on. 68

  12. View: Side Content Preview 69

  13. Definition: Relationships A relationship allows you to expand the original query to include additional objects. ~Matt Tucker, PingVision Find a common item between 2 different objects so you can display related information. If you want to reduce the results and cannot find what you are looking for in “filters”, there is a good chance that it is a “relationship”. 70

  14. Example: Side Content CONTRIBUTED MODULES DOWNLOADED CUSTOM MODULE CREATED • • Views drupalconsf2010: site- • specific customizations Views Exporter • Views UI • CCK • Content • Option Widgets • Node Reference: allows nodes to be related • Text • Node Relationships: “Create and Reference” feature • Modal Frame API: pops up the node add • jQuery UI (plus library) • Back Reference: maintain 1-1 relationships between all shared instances of a nodereference field 71

  15. Example: Side Content APPROACH CREATE VIEW • • Create Content Type Filters • • Create Content Fields • • Create View Arguments • • Filters Relationships • • Fields Block • Arguments • Relationships • Block • Place Block 72

  16. Create Content Type: side_content Remove default “Body” field. admin/content/types/add 73

  17. Create Content Type: side_content Add CCK “Body” field. admin/content/node-type/side-content/fields 74

  18. Create Content Type: side_content Add CCK Node Reference field. admin/content/node-type/side-content/fields 75

  19. Create Content Type: side_content Add CCK Node Reference field. admin/content/node-type/side-content/fields 76

  20. Edit Content Type: page Add CCK Back Reference field. admin/content/node-type/page/fields 77

  21. Edit Content Type: page Add CCK Back Reference field. admin/content/node-type/side-content/fields 78

  22. Edit Content Type: page Configure Node Relationships admin/content/node-type/page/relationships/noderef 79

  23. Create Content: page Result of Node Relationships Configuration node/add/page 80

  24. Create Content: page Result of Node Relationships Configuration node/add/page 81

  25. Create Content Page & Side Content admin/content/node 82

  26. Create View: Side Content 1. Filters • Node: Published = Yes • Node: Type = Is one of Side Content 2. Fields • Node: Title • Content: Body 3. Arguments • Node ID of Page = sidecontent_parent 4. Relationships • Node ID of Page = sidecontent_parent 5. Block: Show Children 83

  27. Create View: Side Content 1. Filters • Node: Published = Yes • Node: Type = Is one of Side Content 2. Fields • Node: Title • Content: Body 3. Arguments • Node ID of Page = sidecontent_parent 4. Relationships • Node ID of Page = sidecontent_parent 5. Block: Show Children 84

  28. Create View: Side Content 1. Filters - Add 85

  29. Create View: Side Content 1. Filters • Node: Published = Yes • Node: Type = Is one of Side Content 2. Fields • Node: Title • Content: Body 3. Arguments • Node ID of Page = sidecontent_parent 4. Relationships • Node ID of Page = sidecontent_parent 5. Block: Show Children 86

  30. Create View: Side Content 2. Fields – Add 87

  31. Create View: Side Content 1. Filters • Node: Published = Yes • Node: Type = Is one of Side Content 2. Fields • Node: Title • Content: Body 3. Arguments • Node ID of Page = sidecontent_parent 4. Relationships • Node ID of Page = sidecontent_parent 5. Block: Show Children 88

  32. Create View: Side Content 3. Arguments – Add 89

  33. Create View: Side Content 3. Arguments – Add 90

  34. Create View: Side Content 3. Arguments – Add 91

  35. Create View: Side Content 3. Arguments – Add 92

  36. Create View: Side Content Arguments - What did we just do? If we are displaying a block of content (related nodes) on a page, the only information we have available to us is node id of the page we are on. We created an argument that is the node id of the page we are viewing AND equal to the value in the node reference of the side content. Page nid argument = Side Content node reference field nid (field_sidecontent_parent) 93

  37. Create View: Side Content 1. Filters • Node: Published = Yes • Node: Type = Is one of Side Content 2. Fields • Node: Title • Content: Body 3. Arguments • Node ID of Page = sidecontent_parent 4. Relationships • Node ID of Page = sidecontent_parent 5. Block: Show Children 94

  38. Create View: Side Content 4. Relationships – Add 95

  39. Create View: Side Content 4. Relationships – Add 96

  40. Create View: Side Content 4. Relationships – Add 97

  41. Create View: Side Content Relationships- What did we just do? On a page, only show content where the page nid = the node reference (parent) nid in the side_content Page nid argument = Side Content node reference field nid (field_sidecontent_parent) 98

  42. Create View: Side Content What is the difference between the argument and relationship we just created? Argument = We want to use information from the url and how we want to use it Relationship = Only show content where the information from the url matches Page nid argument = Side Content node reference field nid (field_sidecontent_parent) 99

  43. Create View: Side Content 1. Filters • Node: Published = Yes • Node: Type = Is one of Side Content 2. Fields • Node: Title • Content: Body 3. Arguments • Node ID of Page = sidecontent_parent 4. Relationships • Node ID of Page = sidecontent_parent 5. Block: Show Children 100

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend