Difference between revisions of "Drupal/C2/User-group-and-Entity-Reference/English"
(Created page with "'''Title of Script:''' User Group and Entity Reference '''Keywords: video tutorial, drupal, New revision, label, Entity reference, Database, Impact, Reference, Sponsored, The...") |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 27: | Line 27: | ||
* Add '''User Group '''fields and | * Add '''User Group '''fields and | ||
* Connect '''Content types '''with '''Entity reference''' | * Connect '''Content types '''with '''Entity reference''' | ||
− | |||
− | |||
|- | |- | ||
Line 48: | Line 46: | ||
{| style="border-spacing:0;" | {| style="border-spacing:0;" | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| '''Part 1''' | ||
+ | |||
+ | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| '''Time''' | | style="border:1pt solid #000000;padding:0.185cm;"| '''Time''' | ||
| style="border:1pt solid #000000;padding:0.185cm;"| '''Narration''' | | style="border:1pt solid #000000;padding:0.185cm;"| '''Narration''' | ||
Line 53: | Line 55: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:05 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:05 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| Let us recall the '''Events''' | + | | style="border:1pt solid #000000;padding:0.185cm;"| Let us recall the '''Events Content type''' we created in the previous tutorial. |
− | We had created the first five fields shown here. | + | We had created the first five '''fields''' shown here. |
+ | |- | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| To create the '''Event Sponsor field''', we need to create the '''User Groups Content type'''. | ||
− | + | |- | |
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| '''User Groups''' are a group of people who come together to organise an event. | ||
− | '''User | + | Examples could be '''Cincinnati User group''', '''Drupal Mumbai group''', '''Bangalore Drupal group''', etc., |
+ | |- | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| Let us first design the '''User Groups''' on a paper. | ||
− | + | |- | |
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| A group can have a website, a contact person, their email and their experience level. | ||
+ | |- | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| '''Drupal''' has default fields for '''URL''' and '''Email''', so we have chosen these '''field types'''. | ||
− | + | |- | |
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| A person’s name can be captured by a '''Name field'''. | ||
+ | But we will use '''Text (plain)''' for now. | ||
− | + | |- | |
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| User experience levels can be one of “'''Beginner, Intermediate, '''or''' Advanced'''”. | ||
+ | |- | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| To implement this, we will choose a '''List (text) field type'''. | ||
− | + | |- | |
− | + | | style="border:1pt solid #000000;padding:0.185cm;"| | |
− | + | | style="border:1pt solid #000000;padding:0.185cm;"| The last '''field''' here is for capturing all the events sponsored by this group. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | |- | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| For this, we can use '''Entity reference field''' to link to an existing '''Events Content type'''. | ||
− | + | |- | |
− | + | | style="border:1pt solid #000000;padding:0.185cm;"| | |
− | + | | style="border:1pt solid #000000;padding:0.185cm;"| Let's set up''' User Groups Content type'''. | |
− | + | ||
− | + | ||
− | + | ||
− | Let | + | |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 133: | Line 145: | ||
* '''Published''' and | * '''Published''' and | ||
* '''Promoted to front page.''' | * '''Promoted to front page.''' | ||
− | |||
− | |||
|- | |- | ||
Line 141: | Line 151: | ||
− | Then uncheck the box for''' Display author and date information''' | + | Then uncheck the box for''' Display author and date information'''. |
|- | |- | ||
Line 155: | Line 165: | ||
| style="border:1pt solid #000000;padding:0.185cm;"| We are redirected to''' Manage fields''' page. | | style="border:1pt solid #000000;padding:0.185cm;"| We are redirected to''' Manage fields''' page. | ||
+ | |- | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"|Here let's change the''' Label''' for the''' Body.''' | ||
− | + | |- | |
− | + | | style="border:1pt solid #000000;padding:0.185cm;"| | |
− | + | | style="border:1pt solid #000000;padding:0.185cm;"|Click on the''' Edit''' button under the''' Operations''' column. | |
− | Click on the''' Edit''' button under the''' Operations''' column. | + | |
− | + | |- | |
− | In the''' Label | + | | style="border:1pt solid #000000;padding:0.185cm;"| |
+ | | style="border:1pt solid #000000;padding:0.185cm;"|In the''' Label field''', let’s type''' User Group Description''' and then click on the''' Save settings''' button at the bottom. | ||
|- | |- | ||
Line 170: | Line 183: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 1:29 | | style="border:1pt solid #000000;padding:0.185cm;"| 1:29 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| For this''' Content type,''' we are only going to set up 5 fields. | + | | style="border:1pt solid #000000;padding:0.185cm;"| For this''' Content type,''' we are only going to set up 5 '''fields'''. |
|} | |} | ||
{| style="border-spacing:0;" | {| style="border-spacing:0;" | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| '''Part 2''' | ||
+ | |||
+ | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| '''Time''' | | style="border:1pt solid #000000;padding:0.185cm;"| '''Time''' | ||
| style="border:1pt solid #000000;padding:0.185cm;"| '''Narration''' | | style="border:1pt solid #000000;padding:0.185cm;"| '''Narration''' | ||
Line 180: | Line 197: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:05 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:05 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| We have already created one field. Let's now create another one. | + | | style="border:1pt solid #000000;padding:0.185cm;"| We have already created one '''field'''. Let's now create another one. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:08 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:08 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| | + | | style="border:1pt solid #000000;padding:0.185cm;"| Click''' Add field''' button. |
|- | |- | ||
Line 192: | Line 209: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:14 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:14 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| Notice that''' Link: field_event_ website''' | + | | style="border:1pt solid #000000;padding:0.185cm;"| Notice that''' Link: field_event_ website field''' is available. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:18 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:18 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| Because we already named it as''' Event website | + | | style="border:1pt solid #000000;padding:0.185cm;"| Because we already named it as''' Event website.''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:22 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:22 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| Re-using a field allows us to re-use a''' table''' in the''' Drupal database.''' | + | | style="border:1pt solid #000000;padding:0.185cm;"| Re-using a '''field''' allows us to re-use a''' table''' in the''' Drupal database.''' |
− | + | |- | |
− | This is done by maintaining different settings for the same field. | + | | style="border:1pt solid #000000;padding:0.185cm;"| |
+ | | style="border:1pt solid #000000;padding:0.185cm;"|This is done by maintaining different settings for the same '''field'''. | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:39 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:39 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| In this case, it makes more sense to set up a new field. | + | | style="border:1pt solid #000000;padding:0.185cm;"| In this case, it makes more sense to set up a new '''field'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:41 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:41 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| In''' Add a new field''' dropdown, choose the''' Link''' | + | | style="border:1pt solid #000000;padding:0.185cm;"| In''' Add a new field''' dropdown, choose the''' Link field type'''. |
Line 222: | Line 240: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 0:51 | | style="border:1pt solid #000000;padding:0.185cm;"| 0:51 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| This time we will select''' External links only''', since no''' User Groups''' actually has a page in''' Drupalville''' yet | + | | style="border:1pt solid #000000;padding:0.185cm;"| This time we will select''' External links only''', since no''' User Groups''' actually has a page in''' Drupalville''' yet. |
|- | |- | ||
Line 233: | Line 251: | ||
− | This time we will use a''' Text''' | + | This time we will use a''' Text field''' for the contact person’s name. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 1:07 | | style="border:1pt solid #000000;padding:0.185cm;"| 1:07 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| Click on''' Add a new field''' dropdown and choose the | + | | style="border:1pt solid #000000;padding:0.185cm;"| Click on''' Add a new field''' dropdown and choose the '''field type Text (plain).''' |
Line 255: | Line 273: | ||
− | This time, let’s choose the''' Email''' | + | This time, let’s choose the''' Email field''' in the dropdown. |
Line 270: | Line 288: | ||
Click on '''Save field settings.''' | Click on '''Save field settings.''' | ||
− | + | |- | |
− | There are no other settings here. | + | | style="border:1pt solid #000000;padding:0.185cm;"| |
+ | | style="border:1pt solid #000000;padding:0.185cm;"|There are no other settings here. | ||
Line 286: | Line 305: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 1 :58 | | style="border:1pt solid #000000;padding:0.185cm;"| 1 :58 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| In the''' Label''' | + | | style="border:1pt solid #000000;padding:0.185cm;"| In the''' Label field''', we will type''' Group Experience''' and then click''' Save and continue''' button. |
|- | |- | ||
Line 317: | Line 336: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 2:42 | | style="border:1pt solid #000000;padding:0.185cm;"| 2:42 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| We have one more field to add here, that is the''' Entity reference''' | + | | style="border:1pt solid #000000;padding:0.185cm;"| We have one more '''field''' to add here, that is the''' Entity reference field'''. |
|- | |- | ||
Line 326: | Line 345: | ||
{| style="border-spacing:0;" | {| style="border-spacing:0;" | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| | ||
+ | | style="border:1pt solid #000000;padding:0.185cm;"| '''Part 3''' | ||
+ | |||
+ | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| '''Time''' | | style="border:1pt solid #000000;padding:0.185cm;"| '''Time''' | ||
| style="border:1pt solid #000000;padding:0.185cm;"| '''Narration''' | | style="border:1pt solid #000000;padding:0.185cm;"| '''Narration''' | ||
Line 335: | Line 358: | ||
* '''Events''' can be sponsored by''' User Groups''' and | * '''Events''' can be sponsored by''' User Groups''' and | ||
* '''User Groups''' can sponsor''' Events'''. | * '''User Groups''' can sponsor''' Events'''. | ||
− | |||
− | |||
|- | |- | ||
Line 393: | Line 414: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 1:15 | | style="border:1pt solid #000000;padding:0.185cm;"| 1:15 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| We are referencing | + | | style="border:1pt solid #000000;padding:0.185cm;"| We are referencing ''' Events Content type.''' |
Line 422: | Line 443: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.185cm;"| 1:51 | | style="border:1pt solid #000000;padding:0.185cm;"| 1:51 | ||
− | | style="border:1pt solid #000000;padding:0.185cm;"| Let's add one more field. | + | | style="border:1pt solid #000000;padding:0.185cm;"| Let's add one more '''field'''. |
Line 460: | Line 481: | ||
− | These are based on''' '''events sponsors and what | + | These are based on''' '''events sponsors and what '''Events''' are being sponsored by what''' User Groups.''' |
Line 481: | Line 502: | ||
* Add '''User Group '''fields and | * Add '''User Group '''fields and | ||
* Connect '''Content types '''with '''Entity reference''' | * Connect '''Content types '''with '''Entity reference''' | ||
− | |||
− | |||
|- | |- | ||
Line 495: | Line 514: | ||
* adapted from Acquia and OSTraining | * adapted from Acquia and OSTraining | ||
* and revised by Spoken Tutorial Project, IIT Bombay. | * and revised by Spoken Tutorial Project, IIT Bombay. | ||
− | |||
− | |||
|- | |- |
Latest revision as of 14:37, 21 July 2016
Title of Script: User Group and Entity Reference
Keywords: video tutorial, drupal, New revision, label, Entity reference, Database, Impact, Reference, Sponsored, Theoretically, Many to many relationship
|
|
Slide 1:
User Group and Entity Reference |
Welcome to the spoken tutorial on User Group and Entity Reference. |
Slide 2:
Learning Objectives
|
In this tutorial, we will learn to
|
Slide 3:
System requirement
|
To record this tutorial, I am using
You can use any web browser as per your choice. |
Part 1 | |
Time | Narration |
0:05 | Let us recall the Events Content type we created in the previous tutorial.
|
To create the Event Sponsor field, we need to create the User Groups Content type. | |
User Groups are a group of people who come together to organise an event.
| |
Let us first design the User Groups on a paper. | |
A group can have a website, a contact person, their email and their experience level. | |
Drupal has default fields for URL and Email, so we have chosen these field types. | |
A person’s name can be captured by a Name field.
But we will use Text (plain) for now. | |
User experience levels can be one of “Beginner, Intermediate, or Advanced”. | |
To implement this, we will choose a List (text) field type. | |
The last field here is for capturing all the events sponsored by this group. | |
For this, we can use Entity reference field to link to an existing Events Content type. | |
Let's set up User Groups Content type. | |
0:10 | Click Add content type. |
0:14 | Let’s name this one as User Groups. |
0:16 | Notice that the Machine name is user_groups. |
0:27 | In the Description, type -
This is where we track the Drupal groups from around the world. |
0:36 | In the Title field label we will name this as User Group Name. |
0:47 | Let's set this up in the same manner as our Events Content type.
|
0:51 | Under Default options, let’s check the boxes for
|
0:57 | Now click on Display settings tab.
|
1:00 | Lastly, click on Menu settings tab, and uncheck the box for Main navigation. |
1:05 | Once we have got that set, we can click on Save and manage fields button at the bottom. |
1:13 | We are redirected to Manage fields page. |
Here let's change the Label for the Body. | |
Click on the Edit button under the Operations column. | |
In the Label field, let’s type User Group Description and then click on the Save settings button at the bottom. | |
We can see the green success message at the top. | |
1:29 | For this Content type, we are only going to set up 5 fields. |
Part 2 | |
Time | Narration |
0:05 | We have already created one field. Let's now create another one. |
0:08 | Click Add field button. |
0:10 | In this case, we will click on Reuse an existing field dropdown. |
0:14 | Notice that Link: field_event_ website field is available. |
0:18 | Because we already named it as Event website. |
0:22 | Re-using a field allows us to re-use a table in the Drupal database. |
This is done by maintaining different settings for the same field. | |
0:39 | In this case, it makes more sense to set up a new field. |
0:41 | In Add a new field dropdown, choose the Link field type.
|
0:45 | Click Save and continue, and then click Save field settings. |
0:51 | This time we will select External links only, since no User Groups actually has a page in Drupalville yet. |
0:58 | Click Save settings button at the bottom. |
1:01 | Once again, click on Add field.
|
1:07 | Click on Add a new field dropdown and choose the field type Text (plain).
|
1:20 | Click Save and continue, and then Save field settings. |
1:26 | Then click on the Save settings button at the bottom. |
1:30 | Once more, click on Add field button.
|
1:40 | In Allowed number of values, we need only 1.
|
There are no other settings here.
| |
1:47 | Once more, click on Add field button. |
1:51 | This time, in the Field type dropdown, select the List (text) option. |
1 :58 | In the Label field, we will type Group Experience and then click Save and continue button. |
2:07 | One of the things about this Field type that should be kept in mind, is given in this message.
|
2:15 | This is one of the reasons we emphasize planning. |
2:18 | Let’s add our values here - Beginner, Intermediate, Advanced, and Expert. |
2:29 | Our User Group could very easily have more than one of these values applicable to them. |
2:36 | Change Allowed number of values from Limited to Unlimited and then click Save field settings. |
2:40 | Now, click Save settings. |
2:42 | We have one more field to add here, that is the Entity reference field. |
2:48 | Now we learn about what is Entity Reference and how to create it. |
Part 3 | |
Time | Narration |
0:05 | One of the things we want to do in our website, is to say that -
|
0:13 | This is a very common thing in a website where you want to link two different content together. |
0:20 | Events are sponsored by User Groups.
|
0:27 | Now let’s set this up.
|
0:32 | If you are a database person, you will recognize these as a many to many relationship within the data. |
0:38 | Click on Add a new field dropdown.
|
0:52 | Next, we are asked to choose the Type of item to reference.
|
0:58 | We are going to keep it very simple - choose Content.
|
1:07 | Here on the Settings page, we get to choose which Content types are referenced by the User Groups. |
1:15 | We are referencing Events Content type.
|
1:27 | Hence, we need to make sure that we have selected the right Content Type here. |
1:30 | Choose Events and click Save settings |
1:34 | Now, we need to do the same thing in our Events Content type. |
1:39 | Click on Structure.
|
1:51 | Let's add one more field.
|
2:03 | Click Save and continue |
2:05 | Change Allowed number of values, let’s choose Unlimited.
|
2:13 | This time under REFERENCE TYPE, choose User groups.
|
2:21 | Click Save settings. |
2:23 | Now this links those two Content Types together in a many to many relationship.
|
Slide 4:
Summary
|
Let us summarize.
|
Slide 5:
Acknowledgement
|
This video is
|
Slide 6:
Acknowledgement
|
The video at this link summarises the Spoken Tutorial project.
|
Slide 7:
Spoken Tutorial Workshops
|
The Spoken Tutorial Project Team conducts workshops and gives certificates.
|
Slide 8:
Acknowledgement
|
Spoken Tutorial Project is funded by
Government of India. |
This is Gautam Narayanan signing off.
|