Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Reusing and grouping fields

From: Drupal 7: Reporting and Visualizing Data

Video: Reusing and grouping fields

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.

Reusing and grouping fields

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.

Show transcript

This video is part of

Image for Drupal 7: Reporting and Visualizing Data
Drupal 7: Reporting and Visualizing Data

44 video lessons · 6757 viewers

Tom Geller
Author

 
Expand all | Collapse all
  1. 13m 50s
    1. Welcome
      50s
    2. What you need to know
      4m 49s
    3. Using the exercise files
      8m 11s
  2. 12m 58s
    1. A yoga studio
      3m 18s
    2. A national organization
      2m 51s
    3. An entertainment company
      4m 3s
    4. An organization with hyperlocal branches
      2m 46s
  3. 40m 49s
    1. Planning your site's data structure
      3m 31s
    2. Creating record templates
      5m 40s
    3. Understanding Drupal 7's data-template model (entities)
      4m 27s
    4. Creating categories using two methods
      6m 14s
    5. Creating unusual field types
      6m 38s
    6. Reusing and grouping fields
      6m 25s
    7. Looking at Drupal's database
      3m 56s
    8. Migrating custom fields from Drupal 6
      3m 58s
  4. 20m 46s
    1. Connecting two fields using references
      5m 35s
    2. Importing data using Feeds
      8m 48s
    3. Changing the appearances of fields
      6m 23s
  5. 53m 15s
    1. Understanding why views are useful
      5m 1s
    2. Learning from built-in views
      5m 52s
    3. Creating and deleting a simple view
      5m 41s
    4. Diving into the Views interface
      8m 48s
    5. Surveying field types
      6m 16s
    6. Adjusting the settings of individual fields
      5m 31s
    7. Sorting and filtering data
      8m 11s
    8. Changing Views' administrative options
      7m 55s
  6. 33m 33s
    1. Varying how a view appears in different displays
      10m 10s
    2. Formatting views with grid, list, table, and jump menu appearances
      6m 43s
    3. Rewriting field output for interesting results
      4m 21s
    4. Creating multipart views using attachments
      6m 8s
    5. Styling the output of views
      6m 11s
  7. 33m 56s
    1. Importing and exporting views
      6m 21s
    2. Controlling access to data
      6m 44s
    3. Adding dynamic filters to views
      5m 41s
    4. Extending views with relationships
      6m 24s
    5. Improving data administration with Views Bulk Operations
      8m 46s
  8. 29m 43s
    1. Understanding locational data
      4m 43s
    2. Setting up the Location module
      9m 42s
    3. Displaying basic maps with the GMap module
      8m 37s
    4. Displaying custom maps
      6m 41s
  9. 23m 50s
    1. Exporting data in simple text form
      7m 4s
    2. Adding dates and calendars
      8m 32s
    3. Displaying content in a slideshow
      8m 14s
  10. 1m 20s
    1. Next steps
      1m 20s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Drupal 7: Reporting and Visualizing Data.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.