Debug Drupal Code
TopicDebugging is the practice of troubleshooting an application through the use of tools and processes in order to find and fix bugs, or better understand the underlying code.
Drupal manages information and access for all visitors to your site, called users, through a system of roles and permissions.
Taxonomy
TopicTaxonomy in Drupal provides a way to classify your site’s content. Taxonomy vocabularies are created with terms within those vocabularies.
As Drupal site-builders and developers we are all very aware that Drupal 7 is not the most useful product out of the box. We constantly add modules and custom code to make Drupal do what we need. There is nothing wrong with this, in fact it is what attracts people to using Drupal in the first place. The block system that comes with core is what we get after installation as our real only means to laying "stuff" out for our website. People have done things like turning nodes into blocks, or making every block on our a site a view. These concepts work, but have a lot of draw backs for usability and performance. There are lots of layout tools to use, but this series is going to take a look at the Context and Bean modules. These two modules are really two completely different modules but when used together give us some pretty powerful options in place of Drupal's core block system.
Additional resources
One of the key problems with the block system in core is it's very limiting. You are limited to a small set of tools for when and how to show a block. Once you lay out your blocks you are basically done—blocks can't be placed in multiple regions. Most importantly, block configurations are not exportable. With the Context module, you lay things out based on the context of your site. A block can exist in one region for one context and a different region for another. Essentially Context is a more advanced block placement form.
In this lesson we'll get started with Context by installing the module on our site, and then walking through the user interface we have to work with. We'll discuss things like conditions and reactions, and see how things are set up.
In this lesson we will build our first simple context. We will create a custom block that contains copyright information. We will use Context and the "site-wide" condition to place this custom block in the footer region of our site.
In this lesson we will perform a simple operation that site builders do when using the Context module. This is not necessary, but a good idea if there are multiple people managing your site. We will disable all blocks in the block UI since we will be using the Context module to manage this part of our website. The core block UI will then only be used to manage block titles as Context does not allow for this (a disadvantage we learned about previously).
In this lesson we will discuss different use cases for when one would use Context module. We will demo a site that has a home page and a user dashboard that acts as an authenticated users home page. We will demonstrate one of the advantages of Context by placing blocks in different locations depending on which page we're looking at.
In this lesson we will go over one of the main reason for using Context over core blocks; exportability. Using the Features module we are able to take all of the work we do in the Context UI and export it as standalone or with other features. The advantage of this is now all of our settings are stored in code and are deployable.
Much like using Context to enhance the core block system, the Bean module takes blocks to a whole new level. The Bean module makes blocks act more like content types. It allows for different block types and for adding fields to blocks. We are also able to manage the display of a block, which comes in handy with Context. We can have a block look different based on the Context of the block.
Additional resources
In this lesson we will install the Bean module and tour the changes it adds to the core block system. We will also look at and learn about block types, and how we can add fields to these types.
Now that Blocks are fieldable and we can have different types, lets demo how this works. In this lesson we will create different block types and show how they can be used just like content. We will also show how we can edit a block that was created with Bean.
In this lesson we will demonstrate how Beans are available in the Context UI. We will place some of the these blocks in different locations and also demonstrate how using different block displays with different context allows us to have a block appear differently based on context.
One of the biggest downsides of the core block system are its permissions. To allow different roles to do different things with blocks is basically an all or none permission. The Bean module provides more granularity for block permissions. We can now add the ability to have site content creators create blocks but not give them permissions to all the other block admin pages.
Additional resources
There are two main areas of translation for your Drupal site: the user interface and the content. The user interface text is mostly provided by the software, stored in the code itself. This is sometimes referred to as "hard-coded." While content is generated by users of the site, and stored in the database. Drupal core comes with the Locale module, which works with the user interface text and gives you a nice set of tools that lets you import existing translations, create or edit your own, or export your site’s translations for use on other sites. In this lesson we'll take a tour of the Locale module and discuss translation files, translating strings, language switching, and how to get a localized installation.
Additional resources
The first step to using any of Drupal’s multilingual features is installing a translation, so that Drupal has more than one language to choose from. As mentioned previously, you can use a localized distribution so that you install your language during the site installation process. Alternatively, you can easily add a language after you have installed the site by using the “Localization update” module. In this lesson we'll get the right pieces in place and get two different languages installed on the site.
Additional resources
Drupal Translations on localize.drupal.org
Using Drupal, 2nd edition
Using Drupal source code
With several language translations installed on our site, we need to make a choice about how and when Drupal will use our new languages. In this lesson, we'll review the Locale module configuration to make sure it is performing the way we want it to, by setting language detection and selection, and then enabling our language switcher.