Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Adobe Digital Marketing

Customizing Content in Drupal 7

Since Drupal’s audience has historically been software developers, that’s translated into strong support for text and add-on programming. Two areas where Drupal has not been as capable are in creating content types with custom fields, and in supporting graphics and text styling within nodes. Fortunately, both areas are getting better. This chapter tells you how to create more flexible content using tools that are available today.
This chapter is from the book

This chapter is from the book

Drupal suffers from the “blind men describing an elephant” syndrome. In that Indian fable, one man touches the trunk and declares that an elephant is like a tree branch; another touches the tail and says an elephant is like a rope; a third touches an ear and says the elephant is like a great leaf; and so forth. The thing observed is seen by its parts, according to the needs of the individual.

Since Drupal’s audience has historically been software developers, that’s translated into strong support for text and add-on programming. Two areas where it’s not been as capable are in creating content types with custom fields, and in supporting graphics and text styling within nodes.

Fortunately, both areas are getting better. This chapter tells you how to create more flexible content using tools that are available today. However, a constant stream of new solutions passes through the library of contributed modules at drupal.org/project/modules. For details on how to find and use them, see Chapter 9, “Extending Drupal with Modules.”

Defining Custom Types of Content

Now we come to one of Drupal’s most useful features: custom content types. Through them you can move far beyond built-in types and into a world bound only by your imagination. For example, an “employee” content type could include fields for position and salary, and a “catalog page” content type would have fields for prices, colors, and sizes.

Nearly all Drupal sites today have custom content types. But amazingly, Drupal succeeded for years without this feature. It was first available in 2005 through a contributed (non-core) module called Flexinode, which was replaced by Content Construction Kit (CCK) in 2006. Now, Drupal 7 incorporates most of CCK in its core.

Although this section teaches how to create new content types, the instructions are essentially the same if you want to edit an existing content type, such as an article or basic page. If you do so, be aware that changes to an existing content type will primarily affect only newly created nodes of that content type. If you add an age field to an existing content type, for example, and require that the age field contain a value, then existing nodes without a value in that field will be unaffected—at least until you go to edit the node. At that point, you’d be prompted to fill in the required field.

To create a new content type:

  1. Click Structure in the Toolbar and then click “Content types.”
  2. Click “Add content type” to go to the content type edit form circle-a.jpg.

    Most of this form is familiar to you, because it looks somewhat like the one you use to create and edit nodes, which you learned about in Chapter 2, “Establishing Your Drupal Site.”

    But there’s an important difference. Changes you make on a node edit form affect only a single node; changes you make on the content type edit form affect every node of that content type. You’re creating a template for future nodes.

  3. Complete the two fields that give the content type its identity:
    • The Name field is where you type the “human-readable” name of the content type. Drupal automatically creates a “machine name” that converts spaces to underscores, and upper-case characters to lowercase characters. (Drupal uses this machine name internally.) However, you can choose to change the machine name by clicking the Edit link in this area circle-b.jpg.
    • The optional Description field is where you add explanatory text that appears on the “Add new content” page to help content editors select the right content type.
  4. Complete the “Submission form settings” section, which controls the appearance of several parts of the node edit form for this content type:
    • The “Title field label” field comes with the default value of Title. I like to change it to something more descriptive, such as Model name circle-c.jpg. You can’t leave this field blank.
    • The “Preview before submitting” setting determines whether node creators see a Preview button at the bottom of the node edit form. If Disabled is selected, they see only the Save button; if Optional is selected, they see both the Save and Preview buttons; and if Required is selected, they see only the Preview button and are allowed to save a node only after previewing it.
    • The “Explanation or submission guidelines” field lets you add a note that appears at the top of the node edit form for the benefit of node creators and editors circle-d.jpg.
  5. Click the “Publishing options” tab circle-e.jpg to set default values for that part of the node edit form. To learn about these settings, see Chapter 3, “Creating and Managing Content.”
  6. Click the “Display settings” tab circle-f.jpg to choose whether a node shows its author and date of creation circle-g.jpg, taken from the “Authoring information” section of the node edit form. Exactly how this information displays is defined by programming in the active theme.
  7. Click the “Comment settings” tab circle-h.jpg to control how visitors can “talk back” in response to nodes:
    • The “Default comment setting for new content” pop-up menu lets you set whether comments will be allowed at all on nodes of this content type. (You can change this setting on individual nodes, however.)

      Open means comments are allowed.

      Closed prevents further comments from being added, but displays any that were already there.

      Hidden means all existing comments will be hidden, and no more will be allowed.

    • Threading affects whether text is indented so that conversations are easier to follow circle-i.jpg. When not selected, all comments appear at the same indentation level. This “flat” format is graphically clean but (sometimes) makes it hard to follow individual conversations, which are known as “threads” circle-j.jpg.
    • The “Comments per page” setting defines how many comments appear before the reader has to click links at the bottom of the page to see more. A low value makes comment pages display more quickly, because there’s less information for Drupal to put together and for the server to push through the Internet. I generally don’t find the delay too onerous, so I usually change it to the maximum value (300).
    • The “Allow comment title” check box determines whether commenters can write their own subject lines. When unselected, or if a commenter fails to provide a title, Drupal automatically creates one using the first few words of the comment. For example, for a comment that reads “I agree very strongly with your post,” Drupal will generate the (somewhat awkward) subject line “I agree very strongly with.”
    • The “Show reply form on the same page as comments” check box determines whether visitors see a comment form directly below the node’s content or have to click an “Add new comment” link to see it. Your choice makes a difference in how many comments you get; it’s surprising how many people won’t bother to click! To encourage more comments, leave this check box selected.
    • “Preview comment” options work very much like those for a node’s “Preview post” options. When you select Required, commenters are forced to read through what they wrote before being allowed to post. In practice, selecting Required means that some commenters will fail to realize that they have to preview their posts before saving them and will simply lose their comments by going to another screen. On the other hand, some administrators believe the Required selection cuts down on frivolous, misformatted, and hot-headed comments.
  8. Click the “Menu settings” tab circle-k.jpg to control where you can put menu links to nodes of this content type when you create or edit nodes. See the section “To create a menu item that links to a node” in Chapter 3 to understand how your choice here affects users. You can always add links from any menu by directly editing it: For details, see Chapter 6, “Improving Access to Content.”
  9. When you’ve made all necessary changes, click “Save content type.”

To change a field’s display and input options:

  1. In the Toolbar, click Structure and then click “Content types.”
  2. Click the “manage fields” link next to the content type you want to affect. Besides being a place to add fields, on this screen circle-l.jpg you can also:
    • Delete a field by clicking its “delete” link, if it’s a type of field that can be deleted. However, you can’t delete fields that modules create or the node’s title field (shown in gray-circle-l.jpg by the name we gave it earlier, “Model name”).
    • Edit the field’s basic criteria by clicking the “edit” link. We discuss the many options on the resulting page in the next step.
    • Change the order of fields by clicking and dragging their drupal-03-29a-1.jpg icons. Note that you have to click Save after reordering fields: You’ll lose all reordering changes if you click other links on this page before clicking Save.
    • Change a field’s type, for example from List to Long text, by clicking the link that shows the current type. For the Body field in gray-circle-l.jpg, that’s “Long text and summary.” (It’s rare that you’ll want to do this.)
    • Change a field’s “widget”—that is, the selection tool for entering data in the field. Examples of widgets included in Drupal include check boxes, radio buttons, pop-up menus, and text fields; contributed modules may add other widgets (such as a date selection calendar). In gray-circle-l.jpg, the widget is currently “Text area with a summary.”
  3. Click the “edit” link to go to the field settings form.

    Options on this form vary considerably, depending on the field’s type and widget. (Our example is of the Integer field type.) In fact, some field types and widgets break these options into more than one screen, in which case you’ll simply have to fill out the first screen, then click “Save field settings” before moving on to the second.

    The screen shown in circle-m.jpg is for a newly created field that’s intended to hold an integer. (You’ll learn how to add fields in the next section, “To add fields to a custom content type.”) The form’s top part is for changing the field’s basic information, including:

    • The Label, which you entered when you first created the field.
    • The “Required field” check box, which determines whether to force node editors to enter a value in this field.
    • The “Help text,” which will appear near the field as a guide for node editors.
    • The Minimum, Maximum, Prefix, and Suffix allow you to limit the range of values the user can enter, or to change how the field appears when displayed. For example, you could put a dollar sign before the value so a “5” appears as “$5.”

    There are many other options, depending on the field type and widget selected. For example, the “Long text and summary” field type includes a “Summary input” check box that lets you permit (or forbid) entry of a summary section. For more about summaries, see the “Gaining More Control of Individual Nodes” section in Chapter 3.

  4. Fill out the “Default value” parts of the field edit form. Whatever data you enter here will appear prefilled in the field when someone later creates a node that contains it.
  5. Complete the “Number of values” pop-up menu that allows you to decide how many values you can have in a multiple value field.

    Multi-value fields can be a hard concept to grasp, and it’s best explained with a few examples. Such a field might be used to show:

    • The names of gold, silver, and bronze medalists in a content type for Olympic sports events. (In that case, you’d set the “Number of values” pop-up menu to 3.)
    • The instruments that a musician plays in an “orchestra member” content type (with the pop-up value set to Unlimited).
  6. When you’ve finished modifying the field’s settings, click “Save settings.”

To add fields to a custom content type:

  1. Click Structure in the Toolbar and then click “Content types.”
  2. Click the “manage fields” link next to the content type you want to change.
  3. Put the human-readable name in the Label area and the machine-readable name in the “Field name” area. Select a field type, which determines the kind of data this field can contain.

    Generally speaking, Drupal’s field types circle-n.jpg fall into five categories:

    • Text, including Text, Long text, and Long text and summary
    • Numbers, including Integer, Float, Decimal, and Boolean
    • Selection lists
    • Files
    • References, for example Term reference. (Downloadable modules permit references to other entities, such as nodes and users.)

    Other field types may become available as you add modules, as Chapter 9 describes.

  4. Once you’ve indicated the type of data this field will contain, the widget pop-up menu becomes available and reflects the widgets for the selected field type. Choose the one you want and then click Save.
  5. The “Field settings” screen displays, where you specify details that are specific to the field type you chose. This section is broken into two screens: The first affects this field in every content type where it appears, while the second is specific to this content type. Complete the field settings form as was described in the section, “To change a field’s display and input options” earlier in this chapter. When you’ve provided all required details, click “Save field settings.” You will return to the list of fields for this content type.
  6. Put fields in the order you want by clicking and dragging their drupal-03-29a-1.jpg icons. Click Save when finished.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020