Create View: Glossary 6. Block Display – Add Arguments 58
Create View: Glossary 6. Block Display – Configure Arguments – Node: Title 59
Create View: Glossary 6. Block Display – Configure Arguments – Node: Title 60
Create View: Glossary 6. Block Display – Preview 61
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
View: Glossary mysite.com/glossary 63
View: Glossary mysite.com/glossary/b 64
View: Glossary mysite.com/glossary/b/blue 65
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
Example 2 Side Content 67
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
View: Side Content Preview 69
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
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
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
Create Content Type: side_content Remove default “Body” field. admin/content/types/add 73
Create Content Type: side_content Add CCK “Body” field. admin/content/node-type/side-content/fields 74
Create Content Type: side_content Add CCK Node Reference field. admin/content/node-type/side-content/fields 75
Create Content Type: side_content Add CCK Node Reference field. admin/content/node-type/side-content/fields 76
Edit Content Type: page Add CCK Back Reference field. admin/content/node-type/page/fields 77
Edit Content Type: page Add CCK Back Reference field. admin/content/node-type/side-content/fields 78
Edit Content Type: page Configure Node Relationships admin/content/node-type/page/relationships/noderef 79
Create Content: page Result of Node Relationships Configuration node/add/page 80
Create Content: page Result of Node Relationships Configuration node/add/page 81
Create Content Page & Side Content admin/content/node 82
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
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
Create View: Side Content 1. Filters - Add 85
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
Create View: Side Content 2. Fields – Add 87
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
Create View: Side Content 3. Arguments – Add 89
Create View: Side Content 3. Arguments – Add 90
Create View: Side Content 3. Arguments – Add 91
Create View: Side Content 3. Arguments – Add 92
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
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
Create View: Side Content 4. Relationships – Add 95
Create View: Side Content 4. Relationships – Add 96
Create View: Side Content 4. Relationships – Add 97
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
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
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
Recommend
More recommend