Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Content types in Drupal 7

Video loading...

  • 0:00
    [robotic voice] Drupalize.Me. [ - Learn Drupal]
  • 0:04
  • 0:06
    [Content types in Drupal 7 - Intro to Fields for Site Builders, Chapter 2 with Karen Stevenson]
  • 0:14
    In this chapter we're going to talk about content types in Drupal
  • 0:17
    and what a content type is and what a field is
  • 0:20
    and how you can put a content type on a field
  • 0:23
    and exactly how all this stuff works in Drupal.
  • 0:28
    So we're going to come over here now
  • 0:29
    and we're going to start by looking at an empty Drupal installation.
  • 0:34
    This is a brand new Drupal 7 installation.
  • 0:36
    I've installed it, but I haven't done anything else to it. It's empty.
  • 0:41
    We're going to see what our options are
  • 0:44
    and what kind of content we can create and how we would go about doing it.
  • 0:50
    I'm sitting here looking at my brand new site,
  • 0:53
    and I can see that up here in the upper left-hand corner
  • 0:55
    I've got this thing that says Add content and Find content.
  • 0:59
    I haven't created anything yet, and I can demonstrate that if I go to Find content
  • 1:04
    I find nothing because there's nothing yet.
  • 1:07
    So let's see what would happen if we go to Add content.
  • 1:11
    What I see is I have out of the box two kinds of content that I can create.
  • 1:16
    I have an article and I have a basic page.
  • 1:20
    It says articles are for time-sensitive content like news, press releases, or blog posts,
  • 1:26
    and a basic page is for static content like an About Us page.
  • 1:30
    So I can create these two different kinds of content.
  • 1:33
    Let's just take a quick look here and see what this is going to give us.
  • 1:37
    Let's say we do want to create an About Us page.
  • 1:40
    Let's create a basic page.
  • 1:43
    You see now I have something called a Title.
  • 1:46
    If this is going to be an About Us page, I guess a title of About Us makes sense.
  • 1:51
    I'm just going to insert some dummy content into that
  • 1:55
    because I don't really care at this point what's in there.
  • 1:57
    If I come down here, I can see I can do some things like put this page into a menu.
  • 2:03
    If I click on this I can say what title do I want in the menu and where do I want it.
  • 2:08
    I'm just going to leave all the defaults.
  • 2:09
    It's going to default to the name of the page that I created,
  • 2:13
    and it's going to put it in the main menu. That sounds good enough.
  • 2:16
    I have some revision information, and I can see from this
  • 2:20
    that I'm going to have some possibilities around creating new revisions of my content.
  • 2:25
    I can set a path if I want to do a custom path for this.
  • 2:30
    I can choose whether or not this content has comments,
  • 2:33
    and for an About Us page that's turned off, which makes sense.
  • 2:39
    I can see I'm going to have some information about who is the author of this content,
  • 2:43
    and I've got some options about how to publish it--
  • 2:47
    whether or not it's published and whether or not it's promoted to the front page.
  • 2:51
    I'm just going to leave all these things at the default
  • 2:53
    because right now we're just trying to kind of see what Drupal is going to do as it stands.
  • 2:58
    So I'm going to save that.
  • 3:01
    What Drupal does when we create content is it takes us to the page that we created.
  • 3:05
    So now I have an About Us page, and it's got the content.
  • 3:10
    Notice that it showed up in the tab.
  • 3:12
    What that menu item did is it gave us a place in the menu.
  • 3:16
    It actually shows up in this case as a tab.
  • 3:19
    The tab isn't exactly where I want it.
  • 3:21
    I probably don't want it showing up before the Home page.
  • 3:24
    Let's see if we can fix that while we're here because I think we can.
  • 3:29
    And sure enough, I have this thing called Weight,
  • 3:31
    and I'm going to just give it a little bit higher weight, and I'll move it down a little
  • 3:36
    so it's not at the beginning.
  • 3:44
    And there we go.
  • 3:45
    Now I've got an About Us page.
  • 3:47
    That was pretty easy.
  • 3:49
    I wonder what the other type of content is.
  • 3:52
    I'm going to go back to Add content.
  • 3:55
    Here's an article. Let's see what an article looks like.
  • 3:59
    Okay. This is interesting.
  • 4:01
    Article has some different fields on it.
  • 4:03
    I have the title page that I had before, so I'm just going to call this My Article.
  • 4:11
    I've got this thing called Tags. That wasn't on my other one.
  • 4:15
    I can do a comma-separated, so let's say this is New, Exciting.
  • 4:20
    And I can give it some dummy content.
  • 4:26
    And I have a field for an image, so I could add an image here.
  • 4:30
    I'm not going to do that right this minute, but I could.
  • 4:33
    I've got the same options down here that I had before.
  • 4:38
    I could in this case allow comments on this page if I wanted to.
  • 4:45
    We'll leave that alone.
  • 4:47
    Most of the other things look about the same as they looked on the other type of content,
  • 4:51
    and I'm going to save that.
  • 4:56
    It's going to take me to this page that it created, and here's my article.
  • 5:01
    My article didn't have a place in the menu, so it's not showing up here,
  • 5:05
    and that makes sense because we don't want every article to show up as a tab on our page.
  • 5:10
    You can see now my article has a place where I can add comments.
  • 5:13
    So I've created another kind of content--in this case an article content.
  • 5:18
    It's got some fields on it that weren't on the page content type.
  • 5:24
    If I go back to my Home page I'm going to see something kind of interesting,
  • 5:28
    and that is now my article didn't show up in the menu but does show up on the Home page.
  • 5:34
    What this is is this is what Drupal calls promoted to the front page.
  • 5:38
    This article was set up to promote to the front page.
  • 5:42
    So now that we see how the page and the article content type work,
  • 5:47
    let's go back and see how are they actually constructed.
  • 5:51
    They had different options, they had different fields.
  • 5:55
    Let's talk about how we would set all that up.
  • 5:58
    The way that we do that, if we look up here at the top of this administration bar
  • 6:02
    across the top of the page, we have something called Structure.
  • 6:06
    If I click on that, I'm going to something here that's going to say
  • 6:11
    I've got some information about Blocks and Content types and Menus and Taxonomy.
  • 6:16
    What I want to look at here is Content types.
  • 6:19
    Here's the content types I just saw.
  • 6:23
    I can see that I'm set up to do two different content types.
  • 6:26
    I have an article content type and I have a page content type.
  • 6:30
    I have some options over here where I can manage the fields
  • 6:33
    or manage the display for these content types.
  • 6:36
    We've seen what they look like. Let's take a look at what these fields look like.
  • 6:42
    I'm going to go into the page first, which was my simpler content type,
  • 6:46
    and you can see my page has a title and it has a body.
  • 6:50
    This body is called Long text and summary,
  • 6:52
    which basically just means it has an option to create a little teaser box
  • 6:57
    as well as a big text area.
  • 7:00
    So it's a text area with summary.
  • 7:02
    I have the fields that I can put on that content type.
  • 7:07
    I have some tabs up here that I can use to manage the way that that content is displayed.
  • 7:13
    And I even have some tabs up here to control the way that comments would be handled
  • 7:19
    if I had comments.
  • 7:21
    In this case I don't have any comments on this content type.
  • 7:25
    Let's go back and look at the other one, just out of curiosity.
  • 7:28
    I go back to Structure, I go to Content types,
  • 7:32
    and let's see what the article looks like.
  • 7:36
    The article has fields, and you can see, as we noticed when we created it,
  • 7:40
    we've got some extra fields on this type.
  • 7:43
    Now we have a thing called Tags, which is taxonomy,
  • 7:46
    which is our reference fields, and this is the place where we could put the tag list.
  • 7:53
    And then we also have an Image field.
  • 7:55
    Neither one of those was on the page content type.
  • 7:59
    What this is showing us is that we can create any number of different kinds of content,
  • 8:04
    and we can put different fields on different content types.
  • 8:09
    One of the first things we want to do is try and understand what a content type is.
  • 8:12
    A content type in one way is content that has different components to it,
  • 8:19
    different fields to it.
  • 8:21
    The page content type is a really simple content type.
  • 8:24
    It only had a title and a body.
  • 8:28
    An article content type was a little bit more complex,
  • 8:32
    and it has a place where you can tag it, give it a reference,
  • 8:36
    and it has a place where you can upload an image.
  • 8:39
    So that starts to give us the idea of how content types work.
  • 8:46
    There's a lot more information that we can dig into about these fields,
  • 8:49
    and we're going to come back to that later,
  • 8:51
    but let's take a look at some other things that we can do while we're here.
  • 8:55
    Notice we've got a bread crumb up here that kind of tells us where we are
  • 8:58
    in the administration area.
  • 9:00
    Let's go back to the Content types page here.
  • 9:04
    Again, we're back to this place where we see the two different content types that we have,
  • 9:09
    and we notice that we have an edit tab for each of these content types.
  • 9:13
    Let's dig into this a little bit and see what's in here.
  • 9:18
    Let's talk about all the different things that are components of this.
  • 9:22
    We see we have a name and then we have this thing called a machine name.
  • 9:26
    Basically, this name is the name that the user is going to see.
  • 9:31
    This is whatever you want your users to call this type of content.
  • 9:36
    We've got this little description that tells us that.
  • 9:38
    This is the human-readable name of the content type.
  • 9:41
    The system is automatically going to make a nice machine name out of that,
  • 9:46
    which is the name that's actually stored in the database.
  • 9:49
    And then we have a description, and this is a description that we can present to the user
  • 9:54
    who is about to create content type to kind of say, what type of content type would this be?
  • 9:59
    Remember we saw this description before.
  • 10:02
    We saw this thing that told us that articles are for time-sensitive content.
  • 10:06
    This is where that description comes from.
  • 10:10
    This is information that tells someone who is about to create content
  • 10:14
    what type of content are they about to create.
  • 10:17
    If we scroll down here a little bit more, we can see that here we had a place
  • 10:21
    where we could identify what the name of the title field is.
  • 10:24
    So we could say Title, which probably most of the time is the right thing,
  • 10:28
    but we could call it Name or we could call it something else if we wanted to.
  • 10:33
    We have some other options that we can set here.
  • 10:35
    We can say Preview before submitting.
  • 10:38
    What this is saying is do we want the user to be forced to do a preview
  • 10:44
    before they submit the article,
  • 10:48
    or do we want them to be allowed to do a preview before they submit it,
  • 10:53
    or do we want to just turn that whole ability to do a preview off?
  • 10:56
    So we have those three options here.
  • 10:59
    And then we have again some more explanation
  • 11:02
    that's going to be displayed to the user if we want to use it.
  • 11:06
    In this case we don't have anything in here.
  • 11:09
    We've got some publishing options.
  • 11:13
    What we're setting here is a little confusing
  • 11:18
    because we had the same kind of publishing options when we actually created the content.
  • 11:21
    This is saying, what are the defaults going to be?
  • 11:24
    What do we want these things to be by default?
  • 11:27
    If somebody is creating a new article, which things do we want checked?
  • 11:32
    And so in the case of an article, we want to automatically have it show up as published,
  • 11:37
    and we want it to automatically show up as promoted to the front page.
  • 11:41
    The person that creates the article is going to be able to uncheck those if they want to,
  • 11:45
    but this is how it's going to default.
  • 11:47
    We have this thing called Display settings.
  • 11:50
    This is kind of interesting.
  • 11:52
    This is telling us, do we want the users of the website to see the author's name
  • 11:59
    and the publication date displayed on the content or not?
  • 12:03
    In the case of an article, again this is defaulting to show that information.
  • 12:09
    We'll go back and take a look at the other side of that in just a second,
  • 12:13
    and you'll see where that shows up.
  • 12:15
    And then this is the place where we can say, what are the comment settings?
  • 12:19
    And again, we had this option when we actually created the article.
  • 12:24
    We had an option to set up the comments.
  • 12:27
    This is saying, what's the default supposed to be?
  • 12:30
    Do we want to allow comments at all on this content type?
  • 12:35
    And if we do, what are the default values going to be?
  • 12:40
    And then we also have a place where we can say,
  • 12:42
    what are the menu options for this type of content?
  • 12:46
    In Drupal 7 we have several different menus.
  • 12:49
    The main menu is the tabs, these things that--
  • 12:53
    Well, when we get back to the Home page we'll see these tabs that show up.
  • 12:57
    That's our main menu.
  • 12:59
    If I go back to where I was, I had some other menu options.
  • 13:06
    We have a Management menu, which is this menu up here.
  • 13:10
    We have a Navigation menu, which will show up in the left-hand column.
  • 13:14
    And we have a User menu,
  • 13:16
    which doesn't really apply to most of the things that we're going to be doing.
  • 13:22
    But we can say which of these menus are available
  • 13:25
    as places that this piece of content could go.
  • 13:29
    We also can say which of those is going to be the default.
  • 13:33
    We saw before that we created the page content type
  • 13:36
    and it went into the main menu,
  • 13:38
    and the article type we didn't put into a menu at all.
  • 13:43
    So now let's go back and look at that content that we created
  • 13:46
    now that we've seen the backside of all this,
  • 13:49
    and let's pull up the article again.
  • 13:51
    Here is the article we created and here's what it looked like.
  • 13:55
    If I go back and edit it, I can again say here's my title,
  • 14:00
    and we know now that it says Title because in the Content settings
  • 14:07
    we told it to have a label of Title.
  • 14:11
    This is where that Tags field shows up that we had in our Manage Fields screen.
  • 14:17
    This is where the Body field shows up that we had in our Manage Fields screen.
  • 14:21
    Remember it had that funny type called Summary,
  • 14:25
    and this is what the summary thing is.
  • 14:27
    It gives the user an option to create a little extra teaser area,
  • 14:32
    and they can either have it or not have it.
  • 14:36
    It's an interesting kind of a content type.
  • 14:39
    This was a filtered type of content.
  • 14:43
    That means the user is going to have an option to be able to put HTML code into this.
  • 14:49
    Here's the image that was added as a field.
  • 14:52
    We can see here Content settings.
  • 14:58
    We've got the defaults on all of these fields
  • 15:02
    that are based on whatever we set up for the content type
  • 15:06
    as the default for this particular type of content.
  • 15:09
    If I go back again a little bit here and look at my article,
  • 15:12
    remember there was that setting to say,
  • 15:14
    do we want to be able to see the author's name and title?
  • 15:18
    On the article we said we did, and here it is.
  • 15:22
    If I go back one more step here and I look at that page that I created,
  • 15:27
    I can see on the page there is no author
  • 15:31
    because we did not say that we wanted the page to display the author and the date.
  • 15:40
    If I look at the back end again of the page,
  • 15:43
    now that I know how this got created, here's the title.
  • 15:46
    I called it Title. Here it is.
  • 15:48
    Here's the body.
  • 15:50
    I've got this funny text and summary page type of field that they can use to create a teaser.
  • 15:57
    And then I've got the menu settings.
  • 15:59
    In here I wanted this page to show up in the menu.
  • 16:04
    I gave it a title, I identified where in the menu it should show up,
  • 16:11
    and I marked it as published.
  • 16:14
    So now I've gone all the way around.
  • 16:17
    I've been able to get a good chance to see what's available in my content.
  • 16:20
    There's one more place that the content type affects things,
  • 16:24
    and that is in Permissions.
  • 16:27
    This is another reason why you might choose one type of content type over another.
  • 16:30
    If I go to the People page here,
  • 16:33
    this gives me all the information about my users.
  • 16:36
    I have a tab called Permissions that shows me what my users have permission to do.
  • 16:42
    If I scroll down here a little bit, I'm going to see some permissions related to content types.
  • 16:48
    For every type of content that I create I've got some permissions that are associated with it.
  • 16:56
    I have two content types. I have basic page and article.
  • 16:59
    Each one of them comes with permission:
  • 17:01
    who can create it, who can edit it, who can delete it.
  • 17:06
    And you can see Create new content, Edit their own content, Edit any content.
  • 17:12
    So for instance, you might have an editor that can edit anybody's article
  • 17:16
    and everybody else can only edit their own articles or whatever.
  • 17:20
    And then for each role that you have you can check or uncheck
  • 17:24
    who has permission to do what.
  • 17:27
    We can see from this that we've got one other reason
  • 17:29
    why we might choose one kind of content over another,
  • 17:32
    and that is because perhaps we want an article to have different permissions
  • 17:36
    than a basic page does.
  • 17:38
    So maybe only the site administrator can create pages,
  • 17:42
    but any authenticated user can create articles.
  • 17:48
    So there's a lot of interesting things that you can do with content types in Drupal.
  • 17:53
    I'm going to go back one more time.
  • 17:55
    We got to Structure, Content types, and this is kind of the main place that we want to go
  • 18:00
    any time we're dealing with content types and the way that they're configured.
  • 18:06
    There are a lot of different things that we can do with content types in Drupal.
  • 18:10
    We can use different fields on them;
  • 18:15
    we can put different permissions on one content type or another;
  • 18:19
    we can group them differently in views;
  • 18:23
    some have comments, some don't;
  • 18:26
    some are in menus, some are not;
  • 18:28
    some display information about the author, some do not.
  • 18:32
    This gives you a sense of the ways that one content type is different from another
  • 18:37
    or can be different from another in Drupal.
  • 18:43
    [robotic voice] Drupalize.Me. [ - Learn Drupal]

Content Types in Drupal 7


Goes through the default content types of the Article and Page that are provided in Drupal 7, and shows the similarities and differences between the two. Also goes through some of the configuration options, which define the default settings whenever a new node is created.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.