Basic Site Building Concepts
In our last lesson we learned about the files that make up a Drupal site, and in particular, which ones were safe to edit and which were best left alone. This time out we're going to review some of the fundamental concepts of Drupal site building.
If you're coming from a WordPress background, you'll know all about plugins, widgets and the like. Drupal has equivalents to these features - and then some. However we're going to begin our discussion with something that is unique to Drupal among the major content management systems, and it's a concept that is often a bit of a head scratcher for newcomers.
Introducing the Node
Most people getting started with Drupal will at some point ask, "What the hell is a node?" The use of the term node is proof positive that Drupal is the work of a developer's mind rather than some slick marketing team.
Although it may be confusing at first, it's actually pretty simple. In Foundation - or your Drupal site of choice - click the Find content menu link. You should see something like the image below.
This list of your site's content is also your list of nodes. A node then, is simply an item of content. The reason the term node is used instead of pageor post, is because in Drupal page or postwould describe particular types of content, and unlike many other content management systems, you can create an unlimited number of content types. Therefore, a generic term for an piece of content was needed, and so we have the humble, although mighty, node.
One thing that often adds to the confusion is that the term page is often used in the same context as node. The reason you'll hear the term page used interchangeably in this way is that nodes eventually end up as a part of a web page - a web page being what your browser displays when you visit a website. In fact, all the bits and pieces of any content management system are ultimately stitched together and displayed as a good old-fashioned web page.
It's difficult to discuss nodes without next discussing content types. Remember, a content type is the same thing as a node type. In Drupal you can easily create as many content types as you like. This makes Drupal a very attractive choice for organizations with complex content - news sites and universities quickly come to mind.
We won't discuss creating new content types in this lesson, but we will talk about the two types that are included with Drupal by default. The first type is the Basic page, which corresponds to a Page in WordPress. The second content type is the Article, which is the Drupal equivalent of a Post in WordPress.
If you were to download and install the popular Webform module, you'd find another content type, Webform, will have automatically been created. In a future lesson we'll go over how you can easily create your own content types to better organize your site.
If you can't wait for that lesson, content types can be found here:
The concept of a block is roughly equivalent to a widget in WordPress, but they are used much more extensively in Drupal. In fact, blocks are what make up most of a typical web page generated by Drupal. Let's take a look the front page of Foundation to demonstrate.
In the image above, all the areas with a colored overlay are blocks. The area in green is the Main page content block. This block contains your node content, that is, what you added to the body field when you created the content.
The other blocks get added either by Drupal, a module you may have installed or by a user with permission to manually create blocks - an admin, for example. You can manage the blocks on your site here:
You'll notice at the top of the Blocks page a link that says, "Add block". You can use that to easily add your own little chunk of block content and then tell Drupal which pages you'd like it to appear on. The blocks system in Drupal is very flexible and very powerful.
We'll discuss blocks more throughout the series, but for now simply make note that they comprise the bulk of any given page and can be generated either by Drupal, a contributed module or manually by a user with the appropriate permissions.
Modules are the workhorses of any Drupal website and there are two types you should be aware of: core modules and contributed modules. Remember what we discussed regarding core in the last lesson? That's right, no hacking core!
So to add functionality to our site, we install contributed modules (so named because they are freely contributed by developers to the Drupal community). There are thousands of contributed modules available and we'll discuss tips for picking the best ones for your site in an upcoming lesson. You can view and manage your site's modules here:
It's important to note that we also shouldn't hack contributed modules. Doing so makes updating them difficult or impossible. If you find something you'd like to change about the way Drupal or a contributed module works, you may be able to override it by creating your own custom module.
Custom modules are outside the scope of what we're going to discuss in this series, but there are many good tutorials for those that are interested.
The important takeaway for now is that Drupal's theme system allows for extensive control over the presentation of every web page generated by Drupal. If you see something styled in a way you don't like on a particular page, you can almost always change it from within your theme.
One of the most powerful ways to override Drupal defaults within your theme is to use a hook. You can use hooks in modules as well, but our focus in a later tutorial will be using hooks in our theme's template.php file. If you're eager for a more in-depth explanation of hooks, this one is great for newcomers.
In Drupal 7, Views is actually a contributed module, but if you're following this series using Foundation, it's already been installed and there are a number of pre-configured views to help get you started. Views is such a critical part of Drupal site building that it has been moved into core in the upcoming Drupal 8.
So what does this super-fantastic module actually do? Perhaps the best way to explain Views is to say it's a query builder on steroids. For example, you can create a view that will query your Drupal database to return all the article content on your site and then display it as a page. This is exactly what is done in Foundation - here's a look at the configuration for the blog view:
We'll touch on views a number of times in upcoming lessons, but if you're working ahead, keep in mind that you can use views to create not only pages and feeds, but also blocks. This functionality is something that really sets Drupal apart from the other major content management systems.
You have an amazing degree of control over the display and placement of your content. You aren't limited to whatever PHP a developer decided to include. Instead you can slice, dice and present your content any which way you like - all without writing code!
Pretty awesome, but that's not to say Views is a breeze. There is a bit of a learning curve, but not to worry, we'll be coming back to it in future lessons.
That's it for this tutorial. You now have a good overview of the fundamental pieces you need to build a Drupal website. Look for another installment later this week. Until then, have fun learning Drupal!