Custom and customized content types

When you create content on your Drupal website, each item of content is described by a content type. Drupal Gardens comes with several standard content types, with each content type containing the information and settings that make it suited for a particular purpose. For example, the Drupal Gardens standard content type "Blog entry" hold three pieces of information (title, body, tags) and has a set of default settings including open comments and being published to the front page.

Technically, a content type is a standardized data model – the collection of data fields (aka "fields": title, body text, etc.) that make up any given item of content. Fields hold data and can extend what any content type (or comments attached to that content type) does – add images, files (attachments), more text, lists or references to other content.

Why custom (or customized) content types or comments?

Site administrators can edit content types' and their comments' standard settings and define custom content types at Structure > Content types. You can customize existing content types and their comments by changing their settings and adding or removing fields. You can also create entirely new content types for specific purposes. But why?

Good reasons to customize a comments, content type or make new ones altogether:

  • Add images to content - If you want to add images to most or all of your blog entries, for example, you could add an image field to it instead of adding inline images.
    • Create teaser images - Adding an image field allows you to use different image variations to be displayed in teaser, full, and other display options.
  • Vertical organization of your site content - Make dynamic pages or blocks of different content types and add menu items for those pages (see: Simple views).
  • Contributor access - Make individual content types for different authors or types of contributor and give them write and edit access to their content type only. (see: User roles and permissions).
  • Visitor access - Make certain content types available only to logged in ("authenticated") users or only to users with certain user roles. (see: User roles and permissions).
  • Downloads - Add downloadable files for your site visitors. Restrict access to this content type by user role if the material isn't for the general public.
  • Tailored data models - All content types, blog entries, forum posts, etc. are different because they fulfill different needs. Make a round peg for a round hole by creating exactly the content type your site needs.

Field widgets

Drupal field widgets are the entry tools used to get data into any given field: text boxes, radio buttons, drop down select lists, etc. When you select a field, you also select the widget you or your users will use to interact with it. Since different data fields take different kinds of input, each field has its own selection of one or more widgets available (a file upload field needs an upload widget, for example, while a text field needs a text input widget).

Widget Description
Autocomplete term widget (tagging) For tagging content from an existing taxonomy vocabulary, this widget suggests existing vocabulary terms while you are typing them in, helping helps avoid repetition and misspellings in tagging taxonomies.
Checkboxes/radio buttons Select a value for fields with multiple, pre-defined options.
File (media) This field is currently under development.
File Upload widget for attaching files to content.
Image Upload widget for attaching images to content.
Select list A drop-down list to select a value for fields with multiple, pre-defined options.
Single on/off checkbox For Boolean (yes/no) fields.
Text area (multiple rows) A larger text entry area. Used by the "Long text" field type
Text area with summary A text entry area with optional, definable summary (teaser) text. This is the field used for the body of content types like Blog entry and Article.
Text field A simple text entry area. For certain kinds of fields, the input value will be validated when content is created or edited (an integer field will only take a whole number, for example).

Fields

Here's a quick run down of the fields available in Drupal Gardens and the widgets for each one:

Default existing fields

These are pre-configured and in use on your Drupal Gardens site. You can add them to your own custom content types, too.

  • Term reference taxonomy_forums (Forums) - Forums in Drupal are organized by taxonomy vocabularies. If you have forums enabled and forum containers in place, adding this field to a content type with a "select list" widget would allow you to add content of this type directly into a forum on your site.
    • Available widgets - select list, checkboxes/radio buttons, autocomplete widget (tagging)
  • Term reference taxonomy_tags (Tags) - Adding this field to your content types allows you to tag it using the same pre-configured tagging vocabulary as Articles, Blog entries and Forum topics and Polls on your site.
    • Available widgets - select list, checkboxes/radio buttons, autocomplete widget (tagging)

New fields

Add new fields to new or existing content types. You may create new fields of all of the following types and configure them to work with any widget available for them.

Field types and widgets:

  • Boolean (yes/no) - Simple yes/no, on/off data field.
    • Available widgets - Select list, Checkboxes/radio buttons, Single on/off checkbox
  • Decimal - Numeric value (decimal)
    • Available widget - text field
  • File - Attach files for user download
    • Available widgets - File, [File (media) under development]
  • Float - Numeric value (floating point http://en.wikipedia.org/wiki/Floating_point)
    • Available widget: text field
  • Image - Attach and display images on content.
    • Available widget: Image
  • Integer - Numeric value (whole number)
    • Available widget: Text field
  • List, List (numeric), List (text) - Fields for various types of lists
    • Available widgets: Select list, Checkboxes/radio buttons
  • Long text - Add texts of one or more paragraphs to content.
    • Available widgets: Text area (multiple rows)
  • Long text and summary - Add texts of one or more paragraphs to content. The summary appears in the content's teaser display and can be separately edited or set to be the first X characters of your content (set under "Display settings" for each content type - go to Structure > Content types, click "edit" next to the content type in question).
    • Available widget: Text area with summary
  • Multimedia asset - Currently under development
    • Available widget: File (media)
  • Term reference - Associate content with taxonomy terms. Depending on the vocabularies you have on your site and the functionality you build in, adding a particular vocabulary and tag this can put a given piece of content into a forum (because Drupal forums are organized by taxonomy terms), add your content to a dynamic page (for example, a Simple View) containing content tagged with a particular term, add it to search results for terms and more.
    • Available widgets: Select list, Checkboxes/radio buttons, Autocomplete term widget (tagging)
  • Text - Add short texts to content.
    • Available widget: Text field

Adding a custom content type

Here's an example of adding a new content type for teams in a company sports league.

  1. Go to Structure > Content types.
  2. Click the Add content type link.
  3. Enter the Name of the new content type, as well as a Description that is displayed on the Add new content page (for example, Team listing for Name, with a Description of Register your team for the company league.).

    Custom content type B1 - Create custom content.png

  4. At the bottom of the page, select the Submission form settings vertical tab, and enter the following information:
    • In the Title field label field, enter a label for the title field of content of this type (for example, Team name).
    • In the Preview before submitting section, select if you want to allow content creators to preview content of this content type before submitting it.
    • In the Explanation or submission guidelines field, enter content input instructions for your content creators (for example, Register your team and players for the upcoming season. May the best team win!).

      Custom content type B2 - Create content type.png

  5. Select the Publishing options vertical tab, and configure your content type using the following options:
    • Use the Default options to determine what Drupal Gardens does by default when content of this content type is created. You can also set these options when content of this type is being individually created.
      • Published - If this checkbox is selected, content is visible by default to all site visitors with the Access content permission. If you deselect this checkbox, content is unpublished by default, and is only visible to its author (assuming the author has the View own unpublished content permission). For information about user permissions, see User roles and permissions.
      • Promoted to front page - Using the standard configuration, your Drupal Gardens site's front page is a blog-style chronological list of content, newest first. Content marked "Promoted to front page" appears here. This is a good setting for blog posts, press releases or similar content where the release time or date can be important. It is not a good setting for "timeless" content like an "about us" page including driving instructions, store hours, and so on.
      • Sticky at top of lists - If this checkbox is selected, content of this type by default appears at the top of any chronologically sorted page it appears on for as long as it remains "sticky". This kind of page includes the standard front page, forum pages and Simple Views. Newer content that would normally supersede it appears below it instead. This functionality is commonly used for important announcements on the front page of a website or to present moderation and behavior guidelines in user forums.
      • Create new revision - If checked, your Drupal Gardens website keeps revision records of all changes to content of this content type. Users making changes to content of this content type are able to enter a log message to help track approvals, launch versions, editorial policy, important points in your site's or content's development, and so on.
    • Enable Multilingual support to be able to mark content as being in a particular language available on your site. For more information about about displaying your website in another language, see Changing your site's displayed language.
  6. Display settings
    • Display author and date information
      • Disabled for the example content type.
  7. Comment settings
    • Threading - Show replies under the comments they pertain to.
    • Comments per page - How many comments to display per page.
    • Default comment setting for new content - Can be set to open, hidden or closed.
    • Anonymous commenting - If the content type you are editing is enabled for Comment notify subscriptions, set whether anonymous site visitors may leave their e-mail address on their comments (and therefore whether they can subscribe to comment notifications).
    • Preview comment - Set whether site visitors can or must preview their comments before posting them.

      Custom content type B4 - Comment settings.png

  8. Menu settings
    • Available menus - Choose in which menus links content of this content type may be included.
    • Default parent item - When making a menu link for content of this content type, it will be included under this item by default, but others may be selected from the available menus on an individual, item-by-item basis.

      Custom content type B5 - Menu setting.png

  9. Depending on your new content type, select from the following options to create the content type:
    • If you don't need further features or custom fields, click Save content type.
    • If you want to add custom data fields to this content type at this time, click Save and add fields.

Adding fields to a content type or its comments

After you create a content type, it and its comments only have a title and a body. You can add and arrange fields on both.

The following example covers adding fields to a content type using the functionality located on the Manage fields and Manage display tabs.

To customize comments for any given content type, the same method applies as shown below, but on the content type's Comment fields and Comment display tabs.

Let's add two more fields to the example "Team listing" content type that we added above:

  • Image field - for a team mascot/avatar to be displayed on teasers and team pages
  • Text field - for the team's motto

Add fields to a content type

  • Go to Structure > Content types and click its "edit" link, then click on the "Manage fields" tab.

    Custom content type B6 - Manage fields.png

  • Image field - team avatar

    Custom content type B7 - Add new field - avatar.png

    • Add image field
      • Use the "Add a new field" row of the Manage fields tab
      • Label the field
        • "Label" is what will appear on the content creation page
        • "Field name" is for the system to keep track of it. It may contain only letters, numbers and underscore characters.
      • Field type and widget - Select the image field type and the image widget
      • Click "Save"
    • Content type-based field settings - After saving the basic properties of the new field (previous step), you are taken to the settings page that controls all aspect of the new field when used on the content type you have assigned it to.
      • Label - This labels the field on the content creation page. If different, the label you enter here overrides the label originally entered on the Manage fields tab previously.
      • Help text - Instructions for users regarding this field. Text you enter here will appear below the field on the content creation/editing page by default.

        Custom content type B8 - avatar field - settings.png

      • Allowed file extensions - Define which file types users may upload.
      • File directory - Keep all files associated with this field in their own directory on your server's file system. Enter a directory name here for it to be created. Directory names may not include slashes, spaces or special characters.
      • Maximum image resolution - Images larger than these dimensions will be automatically resized. Leave blank for no restrictions.
        • Set to 300 x 300 pixels for the example field.
      • Minimum image resolution - Images smaller than these dimensions will be rejected by your site. Leave blank for no restrictions.

        Custom content type B9 - avatar - image settings.png

      • Maximum upload size - The system default (256MB) is more than large enough for the images on our example content type. For other field types (file attachments, for example), it might be necessary to increase this limit.
      • Enable Alt field (accessibility) - This text is displayed if the intended image cannot be displayed for any reason. It is also often read by screen readers.
      • Enable Title field (accessibility) - This text is presented as a hovering "tool tip" in most browsers.
      • Progress indicator - Choose what to display to indicate the image upload is in progress.

        Custom content type B10 - avatar - image size.png

      • Global settings

        Custom content type B11 - avatar - global settings_0.png

        • Public files - If you choose public file storage for images or other attachments, the files are managed by the web server users can download the files directly based on their URLs. Drupal manages files saved in non-public directories, making it harde, but not impossible for users to download them.
        • Default image (optional) - You can upload an image to be displayed as the default avatar on Team profiles without their own image.
      • Number of values - How many images can be attached to this field.
      • Click "Save settings".
  • Text field - team motto
    • Go to Structure > Content types and click its "edit" link, then click on the "Manage fields" tab.

      Custom content type B12 - add new field.png

    • Add text field - Use the "Add a new field" row of the Manage fields tab
      • Label the field
        • "Label" is what will appear on the content creation page
        • "Field name" is for the system to keep track of it. It may contain only letters, numbers and underscore characters.
      • Field type and widget - Select the text field type and the text widget
      • Click "Save".
    • Content type-based field settings - After saving the basic properties of the new field (previous step), you are taken to the settings page that controls all aspect of the new field when used on the content type you have assigned it to.

      Custom content type B13 - motto - settings.png

      • Label - This labels the field on the content creation page. If different, the label you enter here overrides the label originally entered on the Manage fields tab previously.
      • Required field - Making this a required field forces users to enter an allowed value for it when creating or editing this type of content.
      • Size of text field - Display width of text entry box on the content creation/editing page. Not to be confused with the maximum length of the entry allowed in this field!
      • Text format - Whether users must enter plain or formatted text in this field.
      • Help text - Instructions for users regarding this field. Text you enter here will appear below the field on the content creation/editing page by default.
      • Default value (optional) - You can enter a text to be displayed on Team profiles without their own motto.
      • Field settings - these mirror (with the addition of the "Number of values" setting) the field settings as encountered when creating the new image field (see above).
      • Number of values - How many images can be attached to this field.
      • Click "Save settings".

Custom content type B14 - motto - global settings.png

Arrange fields on a content type or its comments (example)

With two new fields added, the "Manage fields" tab of the Team listing content type looks like this. The fields on content of this type will be displayed in the order shown:

Custom content type B15 - team listing page_0.png

To arrange them in a different order, simply drag one by the "+" handle to where you need it. When you are done, click "Save".

Custom content type B16 - team listing order.png

Manage content type display (example)

You can define how content of any given content type is displayed as teasers, in full, in print, in RSS feeds, search indexes, and search results.

To define which fields are displayed (and how they are displayed) in various contexts, go to the "Manage display" tab of the content type in question (Structure > Content types, click "Manage display").

Here are the basic settings for the example content type "Team listing":

  • Teasers
    • Avatar image will be displayed as a thumbnail without a label ("Team avatar" in this case). The thumbnail image is also a link to its Team listing page.
    • Team motto will be displayed without a label ("Team motto" in this case).
    • Team description - The summary (the first 600 characters) will be displayed.
  • Full
    • Avatar image will be displayed with a label ("Team avatar" in this case)
    • Team motto will be displayed with a label ("Team motto" in this case)
    • Team description - The default (full) text will be displayed

Custom content type 17 - manage display.png

Custom content type - create content, set displays (example)

Create a new team

Custom content type B18 - create content.png

Teaser view of the new team - note:

  • unlabeled thumbnail version of avatar
  • unlabeled team motto
  • summary version of the Team description

Full view of the new team - note:

  • full size avatar image displayed with label "Team avatar"
  • team motto displayed with label "Team motto"
  • full Team description text displayed

Add block and page views of a content type

Make custom, dynamic pages of any given content type using Simple views.