If you’re not familiar with Drupal, understanding how a Drupal site fits together can be more than a bit confusing. Whether you’re building or simply adding content to a Drupal site, it’s well worth understanding the basics of how it’s built.

Nodes

The most fundamental and important units of content in Drupal are known as nodes. A node is a chunk of content made of several different pieces of information (known as fields). Fields provide a structured way to describe the content, which the site can then format to display pages. Most of a Drupal site’s content is typically stored in nodes.

Not all nodes are created equal! Each node has a content type, which specifies what fields are used to create that node. For example, you might have a ‘Blog’ content type, which has a headline, body text, publish date, and a thumbnail field. On the same site, you might have a ‘Product’ content type, which has a name, description, images, dimensions, weight, and price. When creating a new Blog node, you’ll only need to input the information relevant to the Blog content type, and when creating a new Product node, you’ll only need to input information relevant to the Product content type.

Perhaps most importantly, each node can be viewed as a page on the site. Every node has a unique URL alias (the part of the URL after the “.com/” or “.net/” or whatever your site domain ends with) which identifies it and displays its contents when someone visits that URL. The URL alias can be changed at any time, giving you complete control over which URLs map to which pages.

Views

The field-oriented nature of nodes becomes invaluable when creating Views. A View is a dynamic list which outputs content in a particular way. Views are typically used to display nodes, but can list other kinds of content stored on the site, such as Users. Views let you specify rules for filtering and sorting content, as well as pick which fields to include and how to format them.

For example, you might create a View of the 5 most recent news articles on your site, with headlines linking to the full articles, and 200 characters of teaser text. You could also create an employee directory, sorted by last name, showing all users and their contact info in a table. If you have a part of a page which pulls together information from several pages and updates automatically when other pages are updated, there’s a good chance it’s powered by a View!

That’s only the beginning of what Views can offer, though. When displayed on a node, a view can also pull in related information, like the bio for a Blog author, or related Products. While that sounds pretty straightforward and basic, it allows for nodes to be set up with rich groupings and relations between them--testimonials which only show up for particular services, a series of articles, several products sold as part of a larger package, etc.

Views can also be set up to display controls for filtering and sorting options. Do users want to filter Blogs by category, or decide whether to sort Products by price or rating? A properly-configured View can offer those sorts of controls and more.

Blocks and Contexts

While nodes and Views provide the ability to store and display information respectively, they say nothing about the layout of the page. Building the structure of the site is done with the aptly-named Block system. Blocks allow you to specify static and dynamic content and control where it’s displayed on the page. A block can be displayed on one page or many, making it easy to get consistent layouts and information. For example, a simple site might use Blocks to place the main menu and telephone number in the header, and a copyright in the footer, for every page. Blocks could also be used to display a newsletter signup or other interactive form in a sidebar, or to display a View of related articles at the bottom of a page.

Block placement gets especially powerful and flexible when using Contexts. A Context allows you to pick specific “conditions” which will trigger a desired “reaction”. For example, you might add a context which says that a “More by this author” block should appear at the top of the sidebar on every “Blog Post” page.

Panels

Placing content on a page is fairly straightforward with views, blocks and contexts, but it’s not a one-size-fits-all solution. While contexts excel in making a small number of reusable block placement rules, they’re less practical for making a large number of rich, custom page layouts. Contexts are also a bit confusing to set up: you first build out all the content (views and blocks) you want to place on a page, then manually type out the particular URLs (and URL patterns) you want to display content on, then finally pick which content you want on which parts of the page. It’s a powerful tool, but even when you master it, it’s still a bit clunky.

Panels helps address this. Similar to blocks and contexts, Panels helps you place content on pages. Unlike blocks and contexts, Panels helps you create reusable layouts, and provides an “in place editor” (IPE) to give a drag-and-drop interface for moving content around on a page. This can make Panels a lot more intuitive to use: on the page you want to add content, you trigger the IPE and press a button to add content. You can pick from existing panes of content (which can be text, menus, blocks, views, or other things) or create new ones, then add them right to the page. Panes can be easily rearranged by dragging them around the page and previewed in real time before being saved.

The Fieldable Panels Panes module further increases the potential for Panels. Fieldable Panels Panes are similar to node content types, allowing you to create custom pane types with specific fields. Do you want to add testimonials on your site with a particular, reused structure, that you can include anywhere on any page? Fieldable Panels Panes might be your best bet.

Putting it all together

That’s a lot of information to process, so let’s recap. A node is a collection of fields of information which can be loaded as a unique page on the site. A view is a list of nodes which has been sorted, filtered, and output in a particular way. A block is an area you can place on the page and put content into, like a picture frame on a wall. A context is a rule that specifies where blocks should be placed and on what (kinds of) pages. A pane is a chunk of content that can easily be placed and rearranged on individual pages.

What does this mean in practice? Let’s say you want to create a store, and when viewing a product, you want to display a list of related products. Here are some of the ways you would leverage nodes, views, blocks and contexts to do this:

  • Create a “Product” content type with fields to store all the information about the product, such as price, rating and category.
  • Add a few Product nodes to the site.
  • Add a few panes to a Product node to create a multi-column layout
  • Create a view of all Product nodes, sorted by highest rating to lowest, which displays the name, price and photo of each product. Make the name and photo link to the respective Product pages.
  • Create another view of all Product nodes. Set this view to display in a block, and create a context which triggers when the user is viewing a Product node and reacts by displaying this block in the sidebar of the page.
  • Modify the view to look up the category of the node it’s being displayed on and filter so it only shows nodes in that same category.

Just like that, you’ve got a basic list of products in the store landing page, and a list of related items when viewing an individual product page. In reality this would just be the start of a store browsing experience, but these systems would still serve as the core of that functionality.With a basic understanding of these building blocks and how they fit together, you'll be able to better understand when developers talk about your Drupal site and be able to communicate more effectively with them.

 

Subscribe to our email list

Subscribe to our email list

Get valuable ideas to build a stronger, faster, and more reliable business.

Join thousands of business leaders on our email list.