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

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?

主站蜘蛛池模板: 大名县| 澄江县| 江川县| 高邑县| 清徐县| 武山县| 军事| 阿勒泰市| 玛多县| 黄平县| 麻江县| 汝南县| 苏尼特左旗| 澄江县| 临沂市| 北碚区| 方城县| 清原| 常宁市| 连山| 厦门市| 嘉峪关市| 湖口县| 清徐县| 泰安市| 汉中市| 长治市| 乌审旗| 诏安县| 祁阳县| 密云县| 内乡县| 醴陵市| 来宾市| 防城港市| 会泽县| 晋宁县| 扶风县| 宁强县| 青川县| 梁平县|