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

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?

主站蜘蛛池模板: 宝鸡市| 湄潭县| 奉化市| 谢通门县| 浪卡子县| 美姑县| 白银市| 金坛市| 贵阳市| 黎川县| 周至县| 康马县| 芜湖市| 西宁市| 雷波县| 乌什县| 南汇区| 富民县| 彭水| 祁阳县| 大同市| 万州区| 大城县| 德惠市| 平邑县| 上思县| 青州市| 五常市| 乾安县| 珲春市| 新平| 平利县| 威宁| 专栏| 新泰市| 台安县| 留坝县| 湛江市| 兴和县| 那曲县| 响水县|