2.3 Creating Your First Content Type
While both articles and basic pages play an important role in Drupal site creation, they can be a little limiting. What if you want to add some customization to make your own content type? This is an area where Drupal really excels. In this lesson, I'll show you how to create your own custom content types.
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
2.3 Creating Your First Content Type
Now at this point, you may be saying to yourself, this is really great. I know how to create basic pages and I can write articles and that's great. But isn't that kind of limiting? So what is the big deal about all this Drupal stuff if all I can do is create articles and pages? Well, you can do so much more than that. So much so that you can create your own content types and be able to integrate them into your site so that anybody could use them. So let's go and see how that might work. Now, you didn't notice when I came in here and I wanted to add content before, I was given the options of Articles and Basic pages, but maybe that's not enough. So this is where we start to dip into some other areas of our administrative toolbar to start to add some more functionality to our site. So these two are a little limiting, I wanna be able to create different types of content. I'm gonna go to Manage and now I'm gonna dip into Structure. Now Structure is what's going to allow me to add some different pieces of functionality, some customizable pieces, that only I can come up with and add to my site. So if you take a look at your Structure, which you can obviously add to your shortcut bar if you do this a lot. But I gonna come down here to Content types. Now in here you see listed Article and Basic page, and I can do some managing operations of those. But I'm gonna take a look at that in an upcoming lesson. So first let's go ahead and create a new customized content type. So here, as in so many other places, we need to provide a name. So in this case I'm gonna say, My First Content Type. And you're gonna see, by default, it's gonna generate a machine name for me which is machine readable. So that it can relate things to this particular type of content later on. And that's one of the really cool features of Drupal. So many magical things are going on behind the scenes that you won't even realize are going on, but it's just doing it all for you, which is incredibly cool. So you can add in a Description if you want, This is my description. And we can come down and do some settings down here. Now typically in here I don't really do much with this, I usually leave a lot of the defaults. But you can change some of these things like the Submission form settings or the Title field. It's actually gonna use the Title field, so this is not where you're gonna edit the text that it's going to submit, it's going to use the Title field. Preview before submitting, you can, but it's optional. Publishing options, we've seen this before. We can it submit them as Published, we can Create a new revision, we can Promote to the front page, a lot of things that we've seen before. Display Settings, do we wanna show the author and the date information? I think so, that should be fine. And then in the Menu settings, where is this going to show up or where can we put these types of contents? And we can put them in the Main navigation, I feel that should be fine. So let's go ahead and hit Save and manage fields. Now, as far as the structure of things go, when you create a content type, you go from content to fields. Fields are just different mechanisms for you to be able to enter in data, like text boxes or date boxes or things of that nature. And this is where you add those types of things in. So now, by default, you are able to add a Body. So now do note that there is some terminology here to know and that are gonna show up in other places as well. So we have a couple different managing options here. So we have Manage fields which means I can add in the associated fields that I want to be here for this particular content type. Manage form display means how is this going to display on the screen when I am editing this information, when I'm adding this information? So when I added content before as an article, how do those text boxes lay out so that I can edit that information or input that information? And Manage display is how is it going to look once I have already submitted it and it's showing up on the website? So we'll come back and take a look at those a little bit later. So let's start with Manage fields. So right now it comes, by default, with a Body, which I think is fine, we can have a Body. Let's add another field. So what type of field do we wanna use? Well, there's so many different types here. Booleans and Comments and Dates and Time and Email as well. I think Date's probably a good one. Let's give this a name and we'll call this maybe Submission date or something like that, so that should be fine. So let's let do Save and continue. And then we can do a little bit of information about this. So what's what sort of Date type, only the Date, Date and time? Maybe how about just a Date, that's fine, we don't need anything else. And how many values can we associate with this? Do we want to allow additional or multiple values? Do we want them to be Unlimited? In this case, I think 1 is probably sufficient for this type of a field. So we're gonna Save field settings, and then we can add a little bit more in here. So our label is Submission Date. We can add some Help text to give a little bit more information. This is the date the information was submitted, or something like that, that should be fine. Whether or not this is a Required field. I don't think it's required, I don't think you have to require this. And then you can specify a Default Value. Do you want a Default Value? Well maybe, let's put it in there as the Current date, just so that there's already something in there and then they can change it if they want. So then we'll do Save settings and there we go, now we have Submission date. And we can continue to do this. So whatever this content type is, maybe it's a review, maybe it is some sort of customized article. Maybe it's a million different things that you can think of that you would want to put in. Maybe it's an event, maybe it's some sort of group or things like that. And whatever sort of fields that are associated with that type of content, you can continue to add these things in here. And there's just a whole slew of different types of things you can put in here. So maybe we wanna put in here a decimal value. Maybe this is gonna be the Price or something like that, so we can go ahead and Save that. Precision, how many total numbers of digits do we want to be able to store? 10 is probably fine. And then how many digits or how many decimal points are the scale? 2 should be fine, and I think we'll limit that to 1, so we'll Save that. This the total cost, I think that's probably fine. Is this required? Sure, we'll make this required. Is there a default? No, there's default, but now are their Minimums and Maximums? Well, we don't wanna allow negatives, so we're gonna say the Minimum is gonna be 0 and the Maximum is maybe 1,000. We don't wanna go much higher than that, and then a Prefix. Do we wanna allow Prefixes? Is there some sort of type of money that we're dealing with here? Do we want to deal with what sort of currency is it, or maybe it's dollars or something like that. And Suffix, maybe we don't need a Suffix, so we're just gonna to Save the settings like that. So now we have these fields, this is going to be what's going to be associated with my content type. Now I can manage the way in the structure and organization that these things show up. So I can come in here and here are my customized versions here. A lot of these things are already there by default, so I'm just going to drag and reorder some of these. So I have my Body, I have my Submission Dates, and I also have my Price. So I'm gonna bring those things up here, just so they're easy to see. And we can see the widgets, and we can see any sort of configuration we have for them. So Submission Date, Price and Body, I think that's probably fine. Or maybe we want the Body to be at the front and then Submission Date and Price, and you can reorder these any way that you want. And any time that you see this gear over here, that means you can simply go in and customize some of the settings here. Like how many rows and Number of summary rows and things like that. So we can be able to change all of those types of things. Let's go and Save those changes and then we can manage the display. So we'll come back to that in a few moments and we'll see how that's going to work. So now, we've done all of this work, let's go ahead and Save, make sure all of this is done and good to go. I can continue to add any sort of number of fields that I want to, but I think at this point, we're probably looking pretty good. So at this point, I'm just gonna Save my content type. And now, as you can see here in Content types, we see My First Content Type and here's my Description, and I can do all sorts of things with it. So let's go ahead and start by creating an instance of My Content Type. So let's go ahead back to my shortcuts. I wanna Add content, and now we see My First Content Type. And now, in here we're going to see exactly what it is I had in the Manage forms display. So I have a Title, An instance of my content type. Some sort of body text. And then we can come down here, we can see a Submission Date. One of the nice things is based on the date or the types of data that you're putting into these, you can get little widgets that show up in here. So I can come in and I could clear this out and it's gonna show that I have a date here. I can use the up and down arrows or I can use the drop down to select a very specific date. So we'll come out here to sometime in February, and now we need to add in a cost, which is, as you can see here, required. So we're gonna say that this is maybe $2.50 or something like that. And I can do all of these types of things over here that I did before, so I don't want this to be a revision. It's not going to be a menu link. I think that should be fine, so let's go ahead and Save and publish. So now here is An instance of my content type, and I see all of this information in here. So now I can see my body, I can see my title, my Submission Date and Price. That's all good stuff. And now I could actually go back Home, and we're gonna see An instance of my content type in a teaser form, as well as My First Article. So now if I ever wanted to view either one of these in full form, I could just click on one of them and I could come over here. But let's just say for this point, I don't really like the way that this is formatted. Let's say I wanted to restructure some of this information so that it was lining up a little bit more to how I envision my entire site looking. And we're gonna take a look at that in the next lesson.