Cài đặt Block improvements trong Drupal 8 rất dễ

Cài đặt Block improvements trong Drupal 8 rất dễ

Blocks in Drupal 7 are pretty useful but, in practice, larger sites often have requirements that core blocks can't support like placing the same block in different regions for different content types. I’m happy to see core blocks have been improved in Drupal 8 to be much more practical and powerful.

I was fortunate to attend the Drupal North conference this month in Montreal. At Drupal North, Ted Bowman gave a nice presentation on the power of Drupal 8 blocks. Ted has also has created a helpful Drupal 8 contrib module called Block Visibility Groups that extends blocks even further.

In his talk, he explained some of the new abilities of blocks including:

  • Blocks can be exported
  • Blocks can be placed in different regions
  • Blocks can have fields

Let’s take a look at these new features and the Block Visibility Groups module in more depth.

Blocks can be exported

First, blocks are now exportable. In Drupal 7, block settings can be moved through the development workflow with Features, but it isn't always reliable. In Drupal 8, block settings are saved in core configuration files and these files can be checked into your favorite code repository such as git.

Example of a block configuration file in D8

D8 Block Configuration Export

Blocks can be placed in different regions

Another improvement in Drupal 8 is that a particular block can be in more than one theme region. For example, if a site needs to have the same block on two different pages in two different regions that is not possible with core blocks in Drupal 7. Site builders have to use other methods, such as using Panels or Context to achieve this.

Now, in Drupal 8, placing the same block in different regions for different pages (or even on the same page!) is possible. Let’s see how that looks.

Example of the "Help" block being placed in two regions

Drupal D8 Block Multiple Regions

Blocks can have fields

Another important difference for Drupal 8 core blocks is that they can have fields. In Drupal 7, we have to use the Bean (Blocks Entities Aren't Nodes) module to have fields on our blocks.

In D8, you can add fields to blocks in the same way you add them to content types or other fieldable entities. This feature changes block versatility immensely! We can have block types of various flavors and use those in intelligent ways. For example, we could have a block type that has just links in it or one with a text blurb and an image. Using block types is much better for structured content (which is the basis of a solid content strategy).

Example of a custom block type with a custom field

Example of D8 Custom Block Type

Blocks are even better with contrib

The block system has improved with the help of D8 contributed modules as well. An excellent example of this is Ted Bowman’s Block Visibility Groups module. With this small module enabled, administrators can manage where all blocks are visible. This admin tool is a valuable UX improvement and an alternative to Panels for less complex sites in Drupal 8.

D8 Block Visibility Group

Have fun with your Drupal 8 blocks!

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

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Bình luận (0)

 

Add Comment

Filtered HTML

  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Các thẻ HTML được chấp nhận: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Tự động ngắt dòng và đoạn văn.

Plain text

  • No HTML tags allowed.
  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Tự động ngắt dòng và đoạn văn.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

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

 
Tỉ phú công nghệ Elon Musk - Ảnh: BUSINESS INSIDER

Tesla tuyển dụng không cần tiến sĩ, không cần tốt nghiệp trung học

Nếu bạn không có bằng đại học hay cao đẳng, điều đó cũng không ngăn được việc bạn trở thành nhân viên của Tesla, tỉ phú công nghệ Elon Musk đã tuyên bố như vậy trên Twitter

Người mẫu Prodan muốn làm bà chủ CLB FC Hermannstadt tại Romania

Người mẫu Prodan muốn làm bà chủ CLB FC Hermannstadt tại Romania

Nữ đại diện, người mẫu Playboy Anamaria Prodan muốn làm bà chủ CLB FC Hermannstadt

Xây dựng Multistep Registration Form trong Drupal 7 dùng Ctools

This article provides a step-by-step tutorial for creating a custom, multistep registration form via the Ctools Form Wizard in Drupal 7

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

 

Diet con trung