5.4 Content Type Entity References
Now that we have all of our content types, we need a way to tie them together. They are all naturally related, and we need a way to represent that within Drupal. We can do just that with entity references.
1.Introduction5 lessons, 42:22
2.Creating Content5 lessons, 42:14
3.Working with Views5 lessons, 34:11
4.Further Configuration3 lessons, 18:12
5.Building a Full Site From Scratch14 lessons, 1:24:52
6.Conclusion1 lesson, 02:26
5.4 Content Type Entity References
Here we are at the point now where we have created the foundational content types that are going to drive the majority of content on our site. And I did mention that these do share relationships between each other. So, for instance, Conferences are going to contain a number of Speakers. And a Conference can also be sponsored by either one or a number of User Groups. And these types of relationships are very common when you are building out websites or even databases or things like that, if you're familiar with those types of concepts. We're starting to talk about this one-to-many or many-to-many relationships, where we can start to build these out in a tool like Drupal, quite simply. So let's go ahead and start to put those concepts together. So let's start with Conferences. So I'm gonna go into Manage fields with Conferences, and I now wanna add a field. And I'm actually gonna wind up adding a couple of fields. So what I wanna do here is I want to create a new field. And now I wanna talk about a reference field. So, this field is now going to reference some other content or some other piece of functionality or something else that's on my site. And so in this case, I wanna refer to Content. Because, ultimately, the content that we're going to refer to is going to be of a certain content type. So in this case, I'm going to call this Conference Speakers. And I'm going to click Save and continue. And at this point, I can select the Type of item to reference. So, once again, I can change my mind if I did select something that was incorrect, but I do wanna stay with Content. And I do want to change this to be Unlimited. Because I could have some unknown number of speakers, and I wanna make sure I can support that. And I wanna Save the field settings. Come in here, where we can leave the Help text. I do want this to be required. And now I can come down here I can give some default Conference Speakers. But I don't wanna do that yet. I wanna save that from the point where I'm actually creating this content. And we can come down here and we can select our Reference method. And we're gonna leave this as the Default. And, now we can select the Content type that we want to refer to, and we wanna to refer to Speakers. And now I can select what I'm going to Sort by. And you could go through this very long list if you would like to pick how you would like to sort these. I guess it really doesn't matter to me too much. It's a fairly lengthy list. But I think for the most part, I'm not overly concerned with what it's gonna sort by. So let's just kind of leave this as None right now. And whatever the default sorting will be fine for now. So let's go ahead and Save settings. And now you see that we have Conference Speakers, which is gonna be an Entity reference. So now we can continue to do this to all of our content types. Let's kinda of Add the rest of these in. So I wanna select a new one. So let's go ahead and add another reference content type here. And this is going to be Sponsored By. And we can Save and continue. And this is going to be by our user groups. And once again, we're going to be Unlimited. Let's go ahead and Save this. And we'll come down here, we'll make this Required. And, once again, I am going to select User Groups. So that's gonna be the references that I want to add to the conferences content type. All right, so let's go back to our Structure and to our Content types. So now we've taken care of Conferences, let's go and do it to Speaker. So, just because we have done it in one direction from Conferences to Speakers, does not mean that it's automatically generated the other way. So if you wanna create that bidirectional relationship, you have to do that manually. So let's come in here and we'll go ahead and Add a field. We'll Select a type. We're gonna once again select Content. And this is going to be Speaking At, how about that? Something along those lines. So we'll go ahead and select the content as what we wanna reference. We want to make this be Unlimited cuz it could once again be any number of conferences. And we're going to make this Required. And we'll come down here and, actually you know what? Let's not make this Required because maybe a speaker is added into the system but he's not speaking anything yet. So let's go ahead and leave that unchecked. And then let's also put in here that we want to speak at particular Conferences. And then we'll go ahead and Save that. So now we have Speaking At. And that's gonna ve ab Entity reference to our conferences. And once again, we'll go back into Structure and Content types. And let's finish up with the User Groups. We'll Manage fields here. We'll go ahead and Add a field. This is going to once again be Content. And this is going to be Conferences Sponsored. Go ahead and Save and continue. And once again, we're gonna make this Unlimited. We'll go ahead and save this. And once again, I don't think this is necessarily gonna be required because we don't know if this user group is gonna sponsor anything yet. But we can obviously go in and modify that. And this is going to be for Conferences. And then we'll go ahead and Save these settings as well. So now, we have our content types pretty much flushed out. And I wanna start adding in some content so we can start seeing what this is gonna look like. But before we get there, I wanna talk about one other very common piece of functionality that is within Drupal that's gonna be coming very handy when you start building out these robust production-level websites. And that's going to be taxonomy.