官术网_书友最值得收藏!

Summary

The Drupal theming system is complex and flexible and thus impossible to cover fully in one chapter of a module development book. However, we did go through the basics necessary to get you started—understanding the core tenets of the theme system, some of its most important Drupal specificities and practical use cases.

We started this chapter by discussing the abstract principle of separating business from presentation logic—a principle that is used by many modern web applications. We saw why it is critical for flexible and dynamic theming. Next, we discussed a great deal about how Drupal does this separation—the mighty theme hooks that act as a bridge between the two layers. Here, we also covered some of the highly used practices surrounding them—preprocessor functions and theme hook suggestions for added flexibility. Then, we covered how the business logic can actually use theme hooks—the render arrays (perhaps one of the most important Drupal constructs). Also, since we were on the subject, we outlined the Drupal and Symfony render pipeline to get a better understanding of the process that builds the entire page render array. Next, we discussed libraries and how we can "attach" them to render arrays. We will definitely see some more examples later in the book when we talk about JavaScript.

Finally, we started transitioning into the practical aspects of theming a module by exemplifying a few common theme hooks found in Drupal core. In doing so, we also encountered the topic of Attributes, an important one to understand when dealing with making theme hooks more dynamic. We ended the chapter with an overhaul of our Hello World salutation message to create a themable component. We did so by putting into practice much of what we learned about theme hooks earlier on: we defined a theme hook and corresponding template, a preprocess function, as well as a theme hook suggestion, and built a render array dynamically to fire them all. Not a bad day in the life of a Drupal 9 module developer.

In the next chapter, we will look at menus and the different types of menu links in Drupal. What kind of web application would it be without any menu links in it?

主站蜘蛛池模板: 招远市| 柘城县| 桓仁| 鄂州市| 富蕴县| 芦山县| 耒阳市| 五河县| 江阴市| 铅山县| 开封县| 云梦县| 太康县| 西安市| 邛崃市| 西昌市| 甘孜县| 大埔区| 明星| 宿州市| 霞浦县| 扶沟县| 鄂尔多斯市| 长乐市| 武夷山市| 惠安县| 连山| 珲春市| 高邮市| 清苑县| 英吉沙县| 四子王旗| 景泰县| 镇原县| 安泽县| 潞城市| 潜山县| 临江市| 青浦区| 海盐县| 黄山市|