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

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?

主站蜘蛛池模板: 澳门| 常州市| 康乐县| 剑河县| 吴桥县| 巴彦县| 古交市| 图木舒克市| 延寿县| 大连市| 肥西县| 射阳县| 荣成市| 佳木斯市| 宾阳县| 淅川县| 庄河市| 丘北县| 靖安县| 论坛| 吉木萨尔县| 盐津县| 罗田县| 洛阳市| 左云县| 竹溪县| 山西省| 株洲县| 玛纳斯县| 邵阳市| 永胜县| 兴安盟| 岳阳县| 陆良县| 正定县| 新密市| 祥云县| 特克斯县| 安宁市| 肥东县| 峡江县|