• No results found

Create the Event Content Type |

In document Design and Prototyping for Drupal (Page 113-119)

But I’m Not a Developer—What if I Don’t Want to Code?

Step 2: Create the Event Content Type |

Creating a content type starts the same as creating a taxonomy vocabulary. This time, you’ll select Structure→Content Types from the admin menu and click the Add content type link.

When creating a content type in Drupal 7, it’s important to remember each of the steps involved in creating them:

• Set up the field’s default settings, then click the Save and Add Fields button to add fields.

• Add any fields you need in your content type, then click the Manage Fields tab to manage how fields are displayed.

• Use the Manage Display area to set up how fields are displayed in different contexts (for example, “teaser” content vs. a single page entry).

This last bit about Manage Display is the one that can trip you up if you aren’t careful. Because Drupal depends on content, and the structure of that content can change dur- ing site implementation—more fields are added or removed, new categories are decided on, etc.—you may find yourself periodically going back and forth and adjusting the content types you’ve created on your site. This is especially true of complex imple- mentations, but it can happen just as easily on a small corporate site. A helpful way to remember it is this: Manage Fields controls where fields show up when you’re creating new content, while Manage Display controls how they show up when that content is displayed.

Figure 12-4. All of the terms that we created for our event categories. Note that they come from the homepage mockup listed at the beginning of the chapter

Figure 12-5 shows what the Manage Fields screen looks like after setting up the Event content type.

Figure 12-5. Our Manage Fields configuration screen, with all the fields from our Event content type

We won’t get into a tutorial on creating fields here; if you’ve never created a content type or added fields before, Sweden’s NodeOne has an excellent series of screencasts that covers the basics of creating basic sites in Drupal 7 (http://dev.nodeone.se/en/learn -drupal-7-with-nodeone). I will point out a couple of things, however:

• The Cost field is set up as an Integer field with a prefix of “$” and a suffix of “USD,” so when rendered, it will show as “$10 USD.”

• The Audience Capacity field is also an Integer field, with a suffix of “ guests,” so when rendered, it will show as “12 guests.”

• The Groups Audience field is a byproduct of the Organic Groups module (dru- pal.org/project/og). As we currently have two primary locations for this site’s events —Cambridge/Somerville and Brooklyn—each location is set up as its own Group. Thus, an event can belong to either the Cambridge/Somerville group or the Brook- lyn group; it’ll show up on the home page of whatever group you’re in.

Now that we have our fields put into the content type, we want to manage how they’re being displayed. For this, we’ll need to visit the Manage Display tab. Before we do that, however, let’s add a test event and check it out to see where we’re starting from.

Figure 12-6 shows our starting point.

Figure 12-6. Our new Event page, with minimum styling. Wait—that’s not in the right order!

As we can see, there’s a whole lot that’s out of order right now. • The additional fields are all out of order

• There’s a bunch of stuff showing that we don’t really need, like the Groups audi- ence and Published date

So, let’s go back to our content type and make some adjustments to the way things display. We’re starting with something like what is shown in Figure 12-7.

Figure 12-7. The Manage Display tab in our Event content type

The first thing we’re going to do is hide some of the things we don’t need to see. We’ll start by setting the Format of the Groups Audience and Who’s Hosting field to Hidden. From there, we’ll set the Labels of all the fields (except for About this Event) to be

Inline instead of Above. Then we’ll rearrange the fields in the order they need to be in:

1. Date and Time 2. Location 3. Cost 4. Bring

5. Audience Capacity 6. About this Event

Now, the Manage Display settings look as shown in Figure 12-8.

Easy, right? Now let’s look at Figure 12-9 to see what it looks like in our sample event.

Step 2: Create the Event Content Type | 101

D o w nl oa d fr om W ow ! eB oo k < w w w .w ow eb oo k. co m >

Figure 12-8. Organizing the fields in our Content Type to better fit our mockup

Figure 12-9. Getting closer, but it still needs work

Now, there are a few things that are still missing here. First of all, we don’t want to show the author information in the content, and we haven’t included an image with the content. This will require a couple of steps. First, in our Event content type, we’re going to go back to the Edit tab, and uncheck “Display author and date information” under Display Settings (Figure 12-10).

Figure 12-10. There’s always something you forget

After we save the content type, we’re going to go back into Manage Fields, and add an Image field to the content type. Next we’ll go into Manage Display and set up the

Image field to have a label that’s hidden. We can then go back into our published event

and add a placeholder image. Now it looks like Figure 12-11. Now we realize another problem: we have to set up image styles.

In document Design and Prototyping for Drupal (Page 113-119)