Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
I'd like to show you two little tricks that are useful when you're building a data-driven site. Neither of these really affect how information is stored or later accessed when you start displaying it with views, but they do affect the forms people see when they enter data and can cut down on some administrative hassles as well. I should mention before we start that I already added a few extra things to this Tags vocabulary down here under Taxonomy. We go into Tags and list terms, we now see we have Outreach, Softball, and Tasting.
I just added them for demonstration purposes, you can add them or not at your choice. They won't make a difference in how your site functions later in the course. On with the show: The first trick lets you reuse one field in more than one content type. I'll show you what I mean. We'll go up and Add content and add an Article. And you'll notice that there's a Tags field here. If I start to type in Softball, it automatically selects it because it knows that there's an item in that Taxonomy called Softball. If I go up and take a look at the content type that creates this, the Article content type, go up to Structure and Content types and Articles, manage fields, we see that the Tags field is right there with an Autocomplete widget.
I'm going to reuse that Tags field in my Employee Content type. To do that, we'll go back to our Content types; I could click up here and go Structure and Content types and so forth. One easier way to do it is to just look at this breadcrumb here and go backward to Content types. And then I'll manage fields in my Employee Content type. Instead of adding a new field, I'm actually going to select one down here. And there it is, our Tags. I'll call that Tags as well. And instead of having it as an Autocomplete, I'll have it as a Select list, Save, and then I have my usual options to choose.
I'll just skip over all of these and Save settings. Now when I add an employee by going to Add content and Employee, indeed I have the Tags field. And you'll notice, even though it contains the same content, that is, it contains the same choices in vocabulary, they're accessed in a different way. And indeed, down at the bottom we have our Tags field here. The only difference is the widget. Instead of being that Autocomplete widget, we can click and Command+Click, Ctrl+Click to select multiple ones and so forth.
But I don't really want to have that in the Employee Content type, so I'll go up to Structure and Content types and down to Employee where I manage fields and delete that field. Now you'll notice it only deletes the content in this field in this content type. So when I click Delete, if I go back now to the other content type that had it, that was the Article Content type, it's still there. We only removed it from the one content type. So that's how you reuse fields and you'll find that handy later on.
For example, let's say you want to create a page that shows everything on the site related to the company softball team. You'd show everything tagged with softball regardless of whether that tag was on an employee or on an article. You could then further configure the page to show a roster of the employees who are on the team alongside all the articles about it. All that by simply selecting the one softball tag that bridges both content types. Now let's move on to the other trick I'd like to show you about field grouping. To make this happen, you have to download and install an extra module.
That module is at drupal. org/project/field_group. I'll scroll down and install it in the usual way. I copy the link location for the .gz file, go back to my site, click Modules, Install the module, paste its URL, and click Install. Then as usual, I enable it. I know that it's not in the Core group, so I can make that smaller by clicking its link here, scroll down a little bit and there it is, Fieldgroup.
Select it, go to the bottom, and Save configuration. You'll see this when we go back and manage the fields within a content type. To do that, I click Structure>Content types and I'm going to manage the fields once again in our Employee Content type. I'm going to add a new group and you'll see a new option down here under Add new field and Add existing field called Add new group. I'll call it Personal; this will be for personal information. And the option I'd use is Fieldset.
Interestingly, you can do all sorts of other interesting effects using this group. You could have it show up in vertical tabs much like at the bottom of a node or horizontal tabs and so forth. I recommend that you check out all of these, they're very interesting. But for now, I'm just going to go down and Save. I'll move that up to the top, and then I'm going to drag some fields into it so that it all gets grouped into one place. I think the First name should go in there and the Family name. And how about the Employee photo along with their Homepage, since it is their personal homepage? Scroll down to the bottom and you'll notice from the little asterisks, that means you have to remember to save otherwise you'll lose that ordering.
Now let's see how that looks when we actually add an employee. Go up to Add content and I'll open that in a new tab. On Windows, I do that by holding Ctrl and on Mac, by holding Command as I click. Add an Employee and you see up here that field group. We can collapse if we want to make it a little bit easier to show and in fact, there were some options back on that earlier page that showed that you can have it start out as collapsed or make it so that it can't be collapsed at all. Once again, I just want to show you what those options are.
I go back to Employee here and if I go up to this little widget, I can see all of my options and I can change those at any time. Again, it's collapsible or not, you can make it so that it's open. If you're a designer and you're good with CSS, you can also add extra CSS classes to it so the field group can really look anyway that you want. That's pretty tantalizing, isn't it? And some of the other options such as vertical tabs are great for organizing input forms as our horizontal tabs and accordion items which work similarly.
They're all well worth exploring, especially on sites where you expect to do a lot of manual data input. A few minutes organizing the fields is well-invested, especially if someone ultimately will have to enter thousands or even tens of thousands of records.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101341 Viewers
61 Video lessons · 88099 Viewers
71 Video lessons · 71950 Viewers
56 Video lessons · 103769 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.