
Creating content types for the teacher blog
In this section, we will outline how to create two content types used in the teacher blog. This section will refer to the process outlined in Chapter 3, Getting Started. When creating a content type you will need to:
- Create the content type
- Add fields to the content type (optional—not all content types require additional fields)
- Assign a taxonomy to the content type (optional—not all content types will be organized using taxonomy)
- Assign permissions to the content type
The blog post content type
The blog post content type will be one of the publishing tools available to users in this site. To create this content type, click on the Structure | Content types link, or navigate to admin/structure/types
.
As described in Chapter 3, Getting Started, to create a new content type, click on the Add content type link.
For the Identification section, use the following values:
- Name:
Blog post
- Description:
Create a blog post
In the Submission form settings section, the Explanation or submission guidelines can be set to: Create your blog post. Enliven your post with relevant details, and describe these details with sumptuous prose.
Tip
The values of the Explanation or submission guidelines section are somewhat arbitrary; while this section can be used to give instructions, it can also be used to have fun. Obviously, the rules of civil and appropriate discourse apply but you can use these instructions to add a touch of unexpected flavor.
In the Workflow settings, set default settings to Published. In the Comment settings section, set the default to Open and configure the comment displays as described in Chapter 3, Getting Started. Click on the Save and add fields button to create the content type.
Adding fields and assigning a taxonomy
On the Manage Fields tab, you can add a copy of an existing field to the content type. Choose Term reference: field_keywords (Keywords) from the Field to share drop-down list. Click on the Save button, and you can configure the field in the same way you did in Chapter 3, Getting Started.

Assigning permissions
Click on People | Permissions | Roles link or navigate to admin/user/rolesadmin/people/permissions/roles
. Click on the edit permissions link for the teacher role.
Tip
Every time we create a new content type, we will need to assign user roles permissions to use the content type. The permissions for content types are usually assigned via the node module.

Note
Assigning a role the Administer nodes permission will allow all users in that role to add, edit, or delete all posts of all content types. Administer nodes permissions should only be assigned to highly-trusted users. The permissions described in this section need to be assigned individually for all content types.
Content types usually have five permissions. For every individual content type, the following permissions can be assigned:
- Create new: This permission allows a user to create nodes of a specific content type
- Edit own: This permission allows user to edit posts they have authored
- Edit any: This permission allows users to edit any post, regardless of who authored it
- Delete own: This permission allows users to delete posts they have authored
- Delete any: This permission allows users to delete any post, regardless of who created it
As shown in the preceding screenshot, we want to assign the teacher role permissions to Create new content, Edit own content, and Delete own content for the blog post. Click the Save permissions button to save the permissions.
Hey! Why not use the blog module?
Drupal comes with a blog module. Although it could be used for this site, we are opting not to use it because of how we are structuring the blog. Unlike more traditional blogs, we will be configuring this blog to make it easy to include audio, video, and images, as well as text. A person's blog will contain the full range of content they create.
Additionally, Drupal's blog module has some features that work better for single user or multiple-user blogs than for this site. These features include some default displays that list all blog posts. For this site, we will be using views to create displays for our content; this allows for a greater degree of flexibility than the blog module. So, rather than trying to override the default behavior of the blog module, we will sidestep the issue entirely.
Creating the assignment content type
To create assignments, we will create another content type. This content type will be very similar to the blog post content type we just created, with one exception: assignments will contain a Date field to allow teachers to specify a due date. As described earlier in this chapter and in Chapter 3, Getting Started, we need to follow these four steps:
- Create the content type
- Add fields to the content type
- Assign a taxonomy to the content type
- Assign permissions to the content type
Getting started – installing modules
To add and display date fields, we need to download and install the Date and Calendar modules. Navigate to the project pages for Date and Calendar at http://drupal.org/project/date and http://drupal.org/project/calendar.
- As described in Chapter 3, Getting Started, upload the modules into the
sites/all/modules
directory. Then, click on the Modules link, or navigate toadmin/modules
as shown in the following screenshot: - Enable the Calendar, Date, Date API, Date Popup, and Date Views modules. These modules are all part of the Date and Calendar modules.
- Click on the Save configuration button to save the settings, and enable the modules.
- You will receive a message stating that you need to set up the site's time zone and first day of the week settings and date format settings. These were set when you installed Drupal, but you may follow the links to further customize if you wish.
The assignment content type
Navigate to Structure | Content types, or admin/structure/types
. Click on the Add content type link.
For the Identification section, use the following values:
- Name:
Assignment
- Description:
Add an assignment
In the Submission form settings section, the Explanation or submission guidelines can be set to: Create an assignment. Remember to set a due date.
In the Workflow settings section, set default settings to Published. In the Comment settings section, set the default to Open, and configure the Comment Display section as described in Chapter 3, Getting Started. Click on the Save and add fields button to create the content type.
Adding fields
Now that we have created the Assignment content type, we need to add a Date field to specify a due date for assignments.
We will then a add a new field, as shown in the following screenshot:

Enter the following values:
- Label:
Due date
- Field name:
due_date
- Field type:
Date
Selecting the field type exposes the form element to edit the data option; select the Pop-up calendar option.
Click on the Save button. This brings up the final settings screen for Date fields, pictured in the following screenshot:

For most uses, including this one, the default settings will work perfectly well. However, we want to highlight five places on this screen that allow you to customize the Date fields in order to make them do exactly what you want. In the preceding screenshot, you will see that we have divided the Edit section into five sections namely, 1, 2, 3, 4, and 5. Let's review these sections:
- Required field (1): As all assignments have due dates, we set this to required.
- Help text (2): The text here will be shown to users as they are creating assignments. For this example, we can use
Enter the date and time when the assignment will be due
. - Date entry options (3): The default value is in military, or 24 hour, time. In some cases, users are more comfortable using A.M./P.M. to indicate times.
- Default date: Set to Now (4). This will autofill the form with the current time, which helps guide users as they fill it out.
- Date attributes to collect (5): The items specified here will be presented to users as options when they create content. For example, if you only want to collect a day, you would set the granularity to Year, Month, and Day. In this example, as we want to set a specific time when assignments are due, we opt to include Hours and Minutes.
Once you have adjusted the settings, click on the Save settings button in order to save your changes.
Ordering fields
After saving your field settings, you will be returned to the MANAGE FIELDS page.

The fields can be adjusted via drag-and-drop. Drag the Due date label to be second on the page. Click on the Save button in order to submit the form and save the changes.
Assigning a taxonomy
As described in Chapter 3, Getting Started, and earlier in this chapter, use the Keyword taxonomy to categorize assignments.
For a greater degree of control, we can create an additional taxonomy for assignments named Type of Assignment. This would allow teachers to apply keywords to the assignments separate from the keywords used for other content. While this is not necessary, increased organization can be useful in larger sites.
Assigning permissions
As described earlier in this chapter, assign the Teacher role permissions to Create new content, Delete own content, and Edit own content for the Assignment content type.
Click on the Save permissions button to save the permissions.