18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1<br />

The responsibility of theming a given piece of data is spread out over the <strong>Drupal</strong><br />

core, the modules, and the applied theme itself. While we don't modify the <strong>Drupal</strong><br />

core code, it is important for developers to be able to understand that both module<br />

code and theme code can manipulate the look and feel of data.<br />

In this book, our focus will be on the module perspective. We work primarily with<br />

theming functions and templates that are defined within the module. Typically, it is<br />

the best practice to work this way first—to ensure that every module has the ability<br />

to theme it's own data.<br />

Menus<br />

<strong>Drupal</strong> not only maintains content, but also details about how the site itself is<br />

organized. That is, it structures how content is related.<br />

The principle way that it does this is through the menu subsystem. This system<br />

provides APIs for generating, retrieving, and modifying elements that describe the<br />

site structure. Put in common parlance, it handles the system's navigational menus.<br />

Two menu systems?<br />

One source of frustration for developers new to <strong>Drupal</strong> is the fact<br />

that the application's front controller is called the menu router.<br />

However, this system is not identical to the menu subsystem. Its<br />

responsibility is to actually map the URLs to callback functions.<br />

We will return to the menu router in later chapters.<br />

Menus are hierarchical, that is, they have a tree-like structure. A menu item can have<br />

multiple children, each of which may have their own children, and so on. In this<br />

way, we can use the menu system to structure our site into sections and subsections.<br />

Nodes<br />

Perhaps the most important subsystem to know is the node system. In <strong>Drupal</strong><br />

parlance, a node is a piece of text-based, publishable content. It can have numerous<br />

fields defined, but typically it has a title, a body, and various pieces of auxiliary data,<br />

such as timestamps, publishing state, and author identification.<br />

Nodes are content<br />

In computer science, the term "node" often has a special meaning.<br />

<strong>Drupal</strong>'s own definition of node is distinct. It is not a point on a<br />

graph, but rather a piece of content. One might prefer to think of<br />

a <strong>Drupal</strong> node as a structured document.<br />

[ 17 ]<br />

www.allitebooks.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!