Lyemium's Guide To Drupal 7

What Can We Do With Drupal?

An advantage in having a complex system allows for flexibility. By having flexibility we can create a wide variety of websites. Before we begin we will highlight the most common question in regards to Drupal; "What can we do with Drupal?" 

Websites with Static Content 

Static content is seen as a site that has information that will remain constant over a period of time without the need for user input. Think of it as your traditional websites that consist of pages and information stored as files on a file system or database. In simpler terms; content that does not change over a period of time. Drupal allows you to create as many unique pages as you like and also has the opportunity to set any particular page you create as the home page.

Websites with Dynamic Content 

Without getting into client-side and server-side scripting; a dynamic web page is a page that displays different content each time it's viewed. For example, the page may change with the time of day, the user that accesses the webpage, or the type of interaction that the user is performing. Web 2.0 is a common buzz word when describing dynamic content. In Drupal a feature like content aggregation is available out of the box. People can subscribe to your dynamic content by utilizing one of the many RSS feeds made available by the system. For more advanced measures modules such as views can play an important role. More information on that later.

Single or Multi-Author Blog

Blogging is popular form of communication especially in the digital age. The Drupal blog module allows each site user to have a blog and their own RSS feed for easy subscriptions. Even if the site has only one author,Drupal contains great features that allow you to get the full experience. The taxonomy portion of Drupal allows you to freely add tags to each post, which can then be displayed as a cloud using modules similar to tagadelic. 

Community Website

One of the more under-rated and overlooked uses for Drupal involves building community websites. It is said that when Drupal was first developed the main focuses was on community and forum-like functionality. In core Drupal includes a user account system and web forums. The user account system allows users to register for an account on your site. In Drupal 7 the ability of fields allows for more control toward the site builder as it enables the admin to set and create the type of information that one would like to capture in a user's profile.
 
Out of the box users are able to upload a small photo to represent their profile. Modules such as Organic Groups and Profile 2 can aid in building a full-featured community website.
 

Structuring

Basic URL Structure for Drupal

A node ID (commonly referred to as nid) is a unique identifier, specific number,  for the content that was created. To determine the nid through the URL of a web page, just use the following URL structure as a guide, where [nid] is the node ID of that page: http://yoursite.com/node/[nid]

Taxonomy

An important feature in Drupal is the taxonomy module which comes with your Drupal 7 installation. The taxonomy system allows you to create a systematic hierarchy which allows you to define vocabularies; these vocabularies can consists of more terms which is essentially your categories. There is no limit to the number of vocabularies you can create and there are no limits to the amount of terms that you can include in each vocabulary. Your vocabulary can also be "free tagging." Free tagging is a field, in Drupal, that allows a user add any term to the content. This is great for ease of use as it eliminates entering specific terms ahead of time. Every tag we add that is freely tag will be added to that specific vocabulary. 

Theme Development Concepts

In Drupal a theme is made up of these major parts:
  • .info – stores information about the different regions, CSS and scripts of the page.
  • page.tpl.php – the default template for pages
  • node.tpl.php – the default template for how a specific node will be displayed. Custom nodes can be created by creating a file using the following naming convention: node-[nodename].tpl.php (e.g. node-blog.tpl.php or node-product.tpl.php)
  • template.php – puts the layout together and calls different functions into the overall layout of each page
  • style.css – all custom CSS for the site

Installing Themes

To enable a downloaded theme:
  • Move the unpacked file into a new directory: /sites/all/themes/[themedirectoryname]
  • Next, choose your theme from Administer > Appearance>
  • Choose which theme you would like as the Default and which ones you would like to have enabled. Any enabled theme can be set as the default theme. Default is important as the Drupal system will use any theme that is currently marked as default 

Fine Tuning

Now that we got some of the basics covered there will be from time to time a moment where you'll spend hours searching through the modules section of drupal.org just to find the right modules needed for a specific task. This guide can not cover every aspect of a site's need but we will highlight some of the more common functionalities to get you up and running. 

Profiles

The more simplified method when it comes to downloading the required modules. Think of profiles as pre-configured bundles, each bundle has certain modules, themes, or pre-built functions that allow you to get your ideal site up and running, instead of you having to physically download and configure multiple modules to extend Drupal core.

Modules 

Modules add functionality to your Drupal site. The core installation of Drupal includes several modules which are known as core modules. There are several key core modules that you should consider enabling on any Drupal-powered website.

Installing Modules

To enable a downloaded module the process is quite similar to installing a new theme:
  • Move the unpacked file into your modules directory: /sites/all/modules/[module-directory-name]
  • Next, choose your module from Administer > Modules
  • Enable your newly downloaded module
If you have drush installed the command would look similar to:
  • drush dl [module name]
  • drush en [module name]
The first command downloads our module while the second command enables it all through the terminal; thus there is no need to manually download and extract files. 
 

The Modules

Now onto the fun part. There are currently over 19,000 modules for Drupal; but who wants to go through all those modules to find out what it's important and currently supported? Since we've done a lot of digging over time here is our list of Drupal 7 modules. 

Administration

  • Admin or Administration menu - Makes navigating through the Drupal backend a breeze. Plays up on the systems strengths while minimizing it's weaknesses. 
  • Features - A feature, in Drupal, is seen as a collection of Drupal entities this making it a great tool to backup resources as well as push new additions from one site to another. If you build a lot of Drupal sites , you may find yourself rebuilding a lot of the same content types, and views. Features helps solve these problems by allowing you to export those content types into a Drupal module.
  • Backup & Migrate - Operates with a similar premise to the features module previously stated. Back & Migrate allows you to easily dump a sites database which is great for migrating a site across different environments. It is also great for scheduled backups that run on cron runs.

Developer Tools

  • Drush - A command line tool. Great for downloading and installing modules as used in our installing modules example. There are many more powerful features to Drush that simplifies the Drupal experience.
  • Devel + Devel Themer - A must have tool for debugging, developing and designing in Drupal.

Site Building

  • Views - A must have module for Drupal 7. How important is it you ask? So important that it will be included in Drupal 8 core. It is estimated that 70% of all Drupal sites use the views module.  Views is a powerful query builder that allows you to write complex queries on the content in your Drupal database and then display the results on a page, block or RSS feed.
  • Panels - Adds the ability to create customized layouts using a drag and drop content manager.
  • Display Suite - Similar to panels display suite allows you to take full control over how your content is displayed using a drag and drop interface. 
  • Context - The new standard for block placement. Want certain blocks to be displayed only on a given page? Context solves this issue.
  • Pathauto - Pathauto allows you to have node aliases set according to a pattern of your choice. Pathauto simplifies creating clean and search engine friendly URLS for the various content you add to your site.
  • Rules - Drupal rules will allow you to set up condition actions. If you find yourself saying "If this happens" "then do this" rules can help you build those actions.
  • Media - The Media module provides an extensible framework for managing files and multimedia assets. This module gives you the ability to upload your images to a library where you can use and reuse them. This module also enables you to plug in with other modules that gives you the ability to link with media resources like YouTube or Vimeo.
  • Path Auto - The standard for automatically generating URL/path aliases for various content
  • Insert - With the Insert module, you can add an image field to your content types. In similar fashion as a WYSIWYG editor. The best part about this module is that it plays nice with many WYSIWYG editors available for Drupal. 
  • Date - Allows ‘date’ fields to be added to content with javascript-powered popup calendars and has Views integration.
  • Email Field - This module provides a field type for email addresses.
  • LoginToboggan - Allows users to login using either their username or their e-mail address. 

Content

  • WYSIWYG - One thing a lot of new users feel is missing from Drupal core is a default HTML rich text editor, referred to as a WYSIWYG (What you see, is what you get). The WYSIWYG module allows for a number of different editors to be easily added to Drupal to make the content creation of Drupal a better experience.
  • Content Access - This module allows you to manage permissions for content types by role and author.
  • Flag - Useful in situations such as:  rating content, creating a 'like' button, flagging offensive comments or 'bookmarking' content.

SEO

  • Global Redirect -  By default, a node's path in Drupal 7 is along the lines of /node/1. Even with path auto enable the default url is still accessible. This is bad as search engines and users now see two unique pages for the same piece of content which can be seen as a duplicate. Search engines tend to penalize you for this duplicate content. What Global Redirect does is set up 301 redirects from the /node/1 url to the alias for that node.
  • XML Sitemap - This module allows Drupal to automatically create an up-to-date sitemap.xml for your website that you can submit to search engines. A sitemaps help crawlers know what content you have on your website that may not be easily accessed otherwise. 
  • SEO Checklist - A Great tool the focuses on the best practices in SEO. It also eliminates the guesswork by creating a functional to-do list

Utilities & API

  • Chaos tools - Also referred to as 'Ctools.'  The views module requires Ctools as a dependency. On its own, Ctools does not seem to do a lot. However, Ctools is a powerful framework when developing your own modules.
  • Token - Tokens are little snippets of text that can be used as replacement patterns.
  • Strongarm - A great module and even better when used in conjunction with the Features module. This module stores Drupal settings in code instead of the database.

Spam Prevention

  • Mollom - Mollom only requires a CAPTCHA if it thinks the poster might be a spammer. This allows for most anonymous users to post to your site without having to enter a CAPTCHA code each time
  • CAPTCHA - Offers similar functionality as the Mollom module. A CAPTCHA is a challenge-response test most often placed within web forms to determine whether the user is human. 
 

Error Handling - The White Screen of Death

When you navigate to your Drupal site and you see nothing but a white blank screen, nicknamed the white screen of death, as a reference to Windows’s blue screen of death, it typically means that Drupal encountered a PHP error. Many things can cause this, and it usually has to do with a development error. Even a missing semicolon can trigger the white screen of death. If you find yourself with a completely blank page, you’ll want to enable PHP error reporting so you can find where the issue is being encountered.

Cache

Drupal creates caches of your content so that every time a page is requested, it doesn’t have to generate it dynamically. The effect is to reduce the amount of PHP processes and SQL queries being made, which in turn increases the performance of your Drupal site. However, if you make certain changes during development, especially a theme, the results may not show up. To get the results that you're looking for you would need to Flush Cache. Flushing your cache clears out your Drupal cache and allows the site to rebuild itself with up-to-date information.
 
The path to flushing cache is as followed: 
  • Configuration > Performance > Clear Cache
  • Drush shortcut to clearing cache: drush cc