Upload
laura-campbell
View
216
Download
0
Embed Size (px)
Citation preview
Parent / ChildParent / Child Data Modeling Data Modeling
1
2
Dennis SolisDennis Solis
Solis Media GroupSolis Media Group Over 20 years of application software Over 20 years of application software
development.development. 3 years of Drupal development3 years of Drupal development Mentor: Drupal Career Starter ProgramMentor: Drupal Career Starter Program Presented a multiple Drupal CampsPresented a multiple Drupal Camps d.o. : densolisd.o. : densolis irc: #drupal-florida irc: #drupal-florida skype: densolis.aol.comskype: densolis.aol.com
Dennis Solis
Born and raised in SFBorn and raised in SF
3
Dennis Solis
Born and raised in SFBorn and raised in SF
4
Living in Cocoa, Living in Cocoa, FlFl
What is Parent ChildWhat is Parent ChildData Modeling?Data Modeling?
Example 1 – Edit Event
5
What is Parent ChildWhat is Parent ChildData ModelingData Modeling
A “different” way of looking at your data.
Visualize how content is related
Relate a node to a nodeNo code and no custom entities
6
How is Parent ChildHow is Parent ChildData Modeling Different?Data Modeling Different?Drupal normal approach is:
Independent content typesTaxonomiesAnd maybe entity references.
Use of the content listNot really user friendly
7
Why change?Why change?
Provides a more “natural” UIAdd a dashboard, which provide easy UI
No longer use the content list!No code and no custom entities
8
PC RelationshipsPC RelationshipsModulesModules
Entity Api entityEntity Reference entityreference Entity Connect entityconnectView viewsEntity Ref Views Widgetentityreference_view_widgetAuto Entity Label auto_entitylabel
9
Drupal Camp PC Data Drupal Camp PC Data ModelModel
10
What data do we need for a Drupal What data do we need for a Drupal Camp?Camp?
Drupal Camp Data ModelDrupal Camp Data Model
11
What data do we need for a Drupal What data do we need for a Drupal Camp?Camp? EventEvent VenueVenue Time slotsTime slots SponsorsSponsors Featured Featured
SpeakersSpeakers DescriptionDescription
NewsNews RoomsRooms SessionsSessions Session Session
SpeakersSpeakers Event typeEvent type
Drupal Camp Data ModelDrupal Camp Data Model
12
12 Content types / taxonomies12 Content types / taxonomies Traditional approach – 12 different Traditional approach – 12 different
menusmenus What is the training curve for a end What is the training curve for a end
user?user?
Drupal Content for DCDrupal Content for DC
13
EventDrupal Camp
NewsFeaturedSpeakers
Sponsors
Time Slots
Venue
ScheduleUsers /
SpeakersSessions
Rooms
Drupal Camp Data ModelDrupal Camp Data Model
14
New employee – first day on the job, New employee – first day on the job, you ask them to enter the Drupal camp you ask them to enter the Drupal camp schedule.schedule.
They have to go to multiple menu They have to go to multiple menu options and enter theoptions and enter the Time slotsTime slots RoomsRooms Experience levelExperience level And the associate Sessions and Speaker And the associate Sessions and Speaker
with the time slot / room.with the time slot / room.
DC Parent Child Data DC Parent Child Data ModelModel
15
The PCDM looks at these items very The PCDM looks at these items very different.different.
This approach is VERY USER CENTRICThis approach is VERY USER CENTRIC Users can access everything from 1 main Users can access everything from 1 main
form!form!
Reduces user training because the data Reduces user training because the data entry process is intuitive.entry process is intuitive.
And views run very fast because And views run very fast because everything is direct access.everything is direct access.
DC Parent Child Data DC Parent Child Data ModelModel
16
EventDrupal Camp
DC Parent Child Data DC Parent Child Data ModelModel
17
EventDrupal Camp
News FeaturedSpeakers
SponsorsTime Slots
Venue Schedule
DC Parent Child Data DC Parent Child Data ModelModel
18
EventDrupal Camp
News FeaturedSpeakers
SponsorsTime Slots
Venue Schedule
Users / Speakers
DC Parent Child Data DC Parent Child Data ModelModel
19
EventDrupal Camp
News FeaturedSpeakers
SponsorsTime Slots
Venue Schedule
Users / Speakers
Sessions
Rooms
DC Parent Child Data DC Parent Child Data ModelModel
20
EventDrupal Camp
News FeaturedSpeakers
SponsorsTime Slots
Venue Schedule
Users / Speakers
Sessions
Rooms
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.
21
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
22
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.
23
Step 1Create Entity Reference
Example 2 Edit the structure of the Event Admin -> Structure -> Content Type ->
Manage Field -> Event Look at the Venue field
24
Step 2Entity Connect
Example 2 Edit the structure of the Event Admin -> Structure -> Content Type ->
Manage Field -> Event Look at the Venue field
25
Step 3 Step 3 Views - Add relationshipsViews - Add relationships Views – Add relationship Referenced
Read child from the parent or Down from parent to child
Referencing Read the parent from the chile or Up to Parent from the child
26
Step 3 Step 3 Views - Add relationshipsViews - 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
27
Step 3 Step 3 Views - Add relationshipsViews - 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
28
Views conditionals
module: views_conditionalmodule: 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..
ExampleExample29
ViewsViewsAdd relationshipsAdd 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.
30
Univ. of Hard Knocks Univ. of Hard Knocks Suggestions for ViewsSuggestions for Views
Include node type in field name Easily find field in views list of fields.
31
UHK Suggestions for UHK Suggestions for ViewsViews
Name content types in singularName content types in singular Names views in pluralNames views in plural
If you name content type and If you name content type and view the same, then views hangsview the same, then views hangs
32
UHK Suggestions for UHK Suggestions for ViewsViews
If using multiple views:If using multiple views: ““All displays” vs “this page”All displays” vs “this page”
Structure -> Views -> SettingsStructure -> Views -> Settings Show the SQL queryShow the SQL query
33
UHK Suggestions for UHK Suggestions for ViewsViews
Make input required BEFORE views Make input required BEFORE views runs.runs.
34
UHK Suggestions for UHK Suggestions for ViewsViews
Page views with same path.Page views with same path. Bad – only one view will appear in the Bad – only one view will appear in the
menumenu Good – if the different views have Good – if the different views have
different role permission, you can have different role permission, you can have multiple views under one menu item – multiple views under one menu item – and role appropriate view will appear.and role appropriate view will appear.
35
UHK Suggestions for UHK Suggestions for ViewsViews
Don’t forget to put in No Results Don’t forget to put in No Results message in your view.message in your view.
36
Congratulation!Congratulation!You are now an Parent Child Expert!You are now an Parent Child Expert!
37