- Drupal 9 Module Development
- Daniel Sipos Antonio De Marco
- 377字
- 2021-06-11 18:36:06
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?
- 新貨幣戰(zhàn)爭
- 淘寶 天貓 微店賺錢從入門到精通:開店、裝修、推廣、管理、安全一本就夠
- 出口跨境電商:速賣通SEO精準(zhǔn)引流與數(shù)據(jù)化運營
- 智能營銷傳播新論
- 新媒體和電商數(shù)據(jù)化運營:用戶畫像+爆款打造+營銷分析+利潤提升(第2版)
- 區(qū)塊鏈社區(qū)運營與生態(tài)建設(shè)
- 微營銷:指尖上的利器
- 首席視頻官:5G時代的短視頻布局與營銷革命
- 新網(wǎng)絡(luò)營銷(微課版)
- B2B網(wǎng)絡(luò)交易實務(wù)
- 淘寶網(wǎng)店金牌客服實戰(zhàn)(第2版)
- 引爆流量:微信小程序運營與推廣
- 網(wǎng)上支付與結(jié)算
- 一部手機(jī)打天下:人類最后的掘金機(jī)會
- 二維碼的秘密:智能手機(jī)時代的新營銷寶典