Drupal/C2/User-group-and-Entity-Reference/English

From Script | Spoken-Tutorial
Revision as of 16:48, 15 July 2016 by Nancyvarkey (Talk | contribs)

Jump to: navigation, search

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


Visual Cue
Narration
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
  • Create User Group Content type
  • Add User Group fields and
  • Connect Content types with Entity reference
Slide 3:

System requirement


To record this tutorial, I am using
  • Ubuntu Operating System
  • Drupal 8 and
  • Firefox web browser

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.


We had created the first five fields shown here.

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.


Examples could be Cincinnati User group, Drupal Mumbai group, Bangalore Drupal group, etc.,

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.


Click on Publishing options tab.

0:51 Under Default options, let’s check the boxes for
  • Create new revision,
  • Published and
  • Promoted to front page.
0:57 Now click on Display settings tab.


Then uncheck the box for Display author and date information.

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.
Time Narration
0:05 We have already created one field. Let's now create another one.
0:08 Just under that, 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, that might be a bit confusing.
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.


In Label, type Group Website.

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.


This time we will use a Text field for the contact person’s name.

1:07 Click on Add a new field dropdown and choose the field type Text (plain).


We will name the Label as Group Contact.

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.


This time, let’s choose the Email field in the dropdown.


We will name the Label as Contact Email.


Click on Save and continue button.

1:40 In Allowed number of values, we need only 1.


Click on Save field settings.

There are no other settings here.


So, we will click on Save settings button at the bottom.

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.


These settings impact the way the data is stored in the database and cannot be changed once data has been created.

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.
Time Narration
0:05 One of the things we want to do in our website, is to say that -
  • Events can be sponsored by User Groups and
  • User Groups can sponsor Events.
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.


So, we want to have the User Group information to be available to every event.

0:27 Now let’s set this up.


Click on Add field.

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.


This time, choose Content under Reference.


In the Label field, we will type Events Sponsored  and then click Save and continue button.

0:52 Next, we are asked to choose the Type of item to reference.


You can see there are a lot of options here.

0:58 We are going to keep it very simple - choose Content.


In Allowed number of values, let’s choose Unlimited.


Then click Save field settings.

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.


Here when I am adding an event, only the events will show up when I start typing the Events title.

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.


Then click on Content types here in the bread crumbs.


Then for the Events Content type, select Manage fields.

1:51 Let's add one more field.


Under Add a new field dropdown, choose Content.


In the Label field, type Event Sponsors.

2:03 Click Save and continue
2:05 Change Allowed number of values, let’s choose Unlimited.


This is because more than one User Group could sponsor an event.


Now click on Save field settings.

2:13 This time under REFERENCE TYPE, choose User groups.


Again, this is because we are referencing User Groups for the Events Sponsors field.

2:21 Click Save settings.
2:23 Now this links those two Content Types together in a many to many relationship.


These are based on events sponsors and what Events are being sponsored by what User Groups.


With this we come to the end of this tutorial.

Slide 4:

Summary


Let us summarize.


In this tutorial we have learnt to

  • Create User Group Content type
  • Add User Group fields and
  • Connect Content types with Entity reference
Slide 5:

Acknowledgement


This video is
  • adapted from Acquia and OSTraining
  • and revised by Spoken Tutorial Project, IIT Bombay.
Slide 6:

Acknowledgement


The video at this link summarises the Spoken Tutorial project.


Pls download and watch it.

Slide 7:

Spoken Tutorial Workshops


The Spoken Tutorial Project Team conducts workshops and gives certificates.


For more details, please write to us.

Slide 8:

Acknowledgement


Spoken Tutorial Project is funded by
  • NMEICT, Ministry of Human Resource Development and
  • NVLI, Ministry of Culture

Government of India.

This is Gautam Narayanan signing off.


Thanks for joining.

Contributors and Content Editors

Nancyvarkey, Priyacst