Sử dụng Field Collection để dễ dàng Re-use Drupal Fields

Sử dụng Field Collection để dễ dàng Re-use Drupal Fields

As with so many of the tutorials we write, this tutorial started as a question in our support forums.

One of our members wanted to set up three image fields and then re-use them across multiple content types. Sử dụng Field Collection để dễ dàng Re-use Drupal Fields

Our solution was to recommend the Field Collection module.

Field Collection allows you (as the name implies) to collect some fields together into a group. You can then re-use those fields for multiple content types, users, comments or really whenever you add fields.

Here's how to use the Field Collection module.

#1. Set up the modules

Field Collection requires that you install just two modules:

Enable those two modules.

#2. Add a Field Collection field

  • Go to Structure > Content types.

media_1376440684887.png

  • Add a field of the type "Field collection".

media_1376440772627.png

#3. Set up the Field collection fields

  • Go to Structure > Field collections.
  • You'll see the field that you created.
  • Click manage fields.

media_1376440824630.png

You'll now see an area very similar to your content type screen. Essentially your "field collection" is an entity that you can add fields to. If you're not sure what an entity is, read our introduction to Entites.

media_1376440843435.png

In this example, I'm going to add three image fields:

media_1376440921328.png

#4. Use the fields

Back in Step #2, you added the field collection to a content type. Click "Add content" and you'll find your reusable images are attached to the content and ready to use:

media_1376440953907.png

#5. Re-use the Field collection

Now that your Field collection is ready, you can use it with any other entity on your site.

You can use the whole Field collection or individual fields within the Field collection:

media_1376441777572.png

 

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
So sánh tính năng giữa iOS 6, Android 4.1 và Windows Phone 8

So sánh tính năng giữa iOS 6, Android 4.1 và Windows Phone 8

iOS 6, Android 4.1 và Windows Phone 8 đều là những bản hệ điều hành mới nhất hiện nay dành cho di động, hai trong số ba cái tên nói trên thậm chí còn chưa có bản chính thức nhưng thông qua các bản beta.

Smartphone Android 2014 có gì đáng xem

Smartphone Android 2014 có gì đáng xem

LG và Samsung đã mang đến cho người dùng sự xuất hiện của chiếc G Flex và Galaxy Round có thiết kế màn hình cong, còn Vivo và Japan Display

Chàng trai Việt ở Google

Chàng trai Việt ở Google

“Nhiệt huyết, tài năng vượt trội nhưng vẫn rất khiêm tốn, lễ phép… Việt Anh là đại diện của một thế hệ trẻ mà quốc gia nào cũng mong có được” – giáo sư Stephen Intille  đã không tiếc...

Công ty diệt chuột T&C

 

Diet con trung