370 likes | 381 Views
Discover a user-centric way to relate content in Drupal, avoiding custom entities and complex menus. Learn how to implement a Parent-Child Data Model for streamlined data management!
E N D
Dennis Solis Solis Media Group Over 20 years of application software development. 3 years of Drupal development Mentor: Drupal Career Starter Program Presented a multiple Drupal Camps d.o. : densolis irc: #drupal-florida skype: densolis.aol.com 2
Dennis Solis Born and raised in SF
Dennis Solis Living in Cocoa, Fl Born and raised in SF
What is Parent ChildData Modeling? Example 1 – Edit Event
What is Parent ChildData Modeling A “different” way of looking at your data. Visualize how content is related Relate a node to a node No code and no custom entities
How is Parent ChildData Modeling Different? • Drupal normal approach is: • Independent content types • Taxonomies • And maybe entity references. • Use of the content list • Not really user friendly
Why change? Provides a more “natural” UI Add a dashboard, which provide easy UI No longer use the content list! No code and no custom entities
PC RelationshipsModules Entity Apientity Entity Reference entityreference Entity Connect entityconnect View views Entity Ref Views Widget entityreference_view_widget Auto Entity Label auto_entitylabel
Drupal Camp PC Data Model What data do we need for a Drupal Camp?
Drupal Camp Data Model • News • Rooms • Sessions • Session Speakers • Event type • Event • Venue • Time slots • Sponsors • Featured Speakers • Description What data do we need for a Drupal Camp?
Drupal Camp Data Model 12 Content types / taxonomies Traditional approach – 12 different menus What is the training curve for a end user?
Drupal Content for DC Event Drupal Camp Sponsors Featured Speakers News Venue Users / Speakers Sessions Schedule Time Slots Rooms
Drupal Camp Data Model • New employee – first day on the job, you ask them to enter the Drupal camp schedule. • They have to go to multiple menu options and enter the • Time slots • Rooms • Experience level • And the associate Sessions and Speaker with the time slot / room.
DC Parent Child Data Model The PCDM looks at these items very different. This approach is VERY USER CENTRIC Users can access everything from 1 main form! Reduces user training because the data entry process is intuitive. And views run very fast because everything is direct access.
DC Parent Child Data Model Event Drupal Camp
DC Parent Child Data Model Event Drupal Camp News Venue Schedule Featured Speakers Time Slots Sponsors
DC Parent Child Data Model Event Drupal Camp News Venue Schedule Featured Speakers Time Slots Sponsors Users / Speakers
DC Parent Child Data Model Event Drupal Camp News Venue Schedule Featured Speakers Time Slots Sponsors Rooms Users / Speakers Sessions
DC Parent Child Data Model Event Drupal Camp News Venue Schedule Featured Speakers Time Slots Sponsors Rooms Users / Speakers Sessions
Simple UI Everything, except creation of sessions, is accessed from the Event. You only need on menu option for the Event! Simplify it even more that creating a dashboard that is automatically presented at login.
Content Types • Create your content from the bottom up. • Lowest content in the parent child relation ship first. • Have the parent reference the child using entity relationship. • We will “connect” the different content types using: • Entity Connect • Entity view widgets
3 Parts to aRelationship Create relationship using entity reference in your content types. Use entity connect to put edit / add icons on your page. Use views to display the related data.
Step 1Create Entity Reference • Example 2 • Edit the structure of the Event • Admin -> Structure -> Content Type -> Manage Field -> Event • Look at the Venue field
Step 2Entity Connect • Example 2 • Edit the structure of the Event • Admin -> Structure -> Content Type -> Manage Field -> Event • Look at the Venue field
Step 3 Views - Add relationships • Views – Add relationship • Referenced • Read child from the parent or • Down from parent to child • Referencing • Read the parent from the chileor • Up to Parent from the child
Step 3 Views - Add relationships • Example 3 – View DC Sessions • Referenced – Read entity referenced from source • View is based upon Event and reading Session’s Date / Time, Title, and Presenters
Step 3 Views - Add relationships • Example 4 – View Event Sessions • Referenced – Read entity referenced from source • View is based upon Event Contextual Filter and reading Session’s Date / Time, Title, and Presenters
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
ViewsAdd relationships • Views – Add relationship (Example 4) • Referenced – Read entity referenced from source. (Down from parent to child) • View is based upon Customer Order and reading Staff, and Dish information • Referencing – Read up to source from entity reference. (Up from child to parent) • View is based upon Staff and reading Customer Order information.
Univ. of Hard Knocks Suggestions for Views • Include node type in field name • Easily find field in views list of fields.
UHK Suggestions for Views Name content types in singular Names views in plural If you name content type and view the same, then views hangs
UHK Suggestions for Views • If using multiple views: • “All displays” vs “this page” • Structure -> Views -> Settings • Show the SQL query
UHK Suggestions for Views 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.
UHK Suggestions for Views Don’t forget to put in No Results message in your view.
Congratulation! You are now an Parent Child Expert!