5.x

Single Sign-on across Sub-Domains in Drupal with No Extra Modules

By Nate HaugArticle23 comments

With the multitude of single sign-on modules out there for Drupal, it's easy to miss the fact that Drupal has a built-in single sign on mechanism already. No modules, no configuration, just 20 easy lines of PHP in your site's settings.php file. This solution works for a lot of clients, but the set of requirements is pretty specific as to when you can use this approach. This includes:

  • The sites sharing a single log-in must be on the same domain. For example:
    • www.example.com
    • forums.example.com
    • subsite.example.com
  • You must be using MySQL.
  • Your sites must be on the same hardware cluster to be able to query each other's databases.

If your site fits within those requirements, you're on your way to simple, efficient, and easy Single Sign-on!

The concept for this single sign-on approach is based around Drupal's ability to prefix database tables. As you may know, you can run multiple Drupal sites on the same MySQL database. However, most sites are not configured this way, each site is given it's own dedicated database. Drupal's table prefixing can be combined with MySQL's ability to query across databases to make a simple "shared table" across multiple sites. Then you just need to set a cookie domain so that the two sites share session information and you're done! read more »

Free Drupal CCK & Views Video Chapters

By Kent ByeArticle1 comment

We've had many requests for sample videos from the Lullabot Learning Series. We decided to post an entire chapter from each video. We tried to pick a chapter that was full of useful information on its own and we placed them on both YouTube and Blip, so feel free to spread them around and embed them on your favorite web page.

Hope you enjoy these videos!

Learning CCK for Drupal

Learning CCK DVD In Learning CCK, Jeff Eaton, Nate Haug, and James Walker show everything from CCK basics such as adding and displaying fields to more advanced topics such as CCK’s database storage mechanisms, field-level permissions, and how to theme CCK’s output. Each chapter of this video builds upon the last as the team builds and configures the content types for a university job board. This video pairs well with Learning Views, which continues this job board project through to completion.

Chapter 3: Adding a CCK field

Drupal, duplicate content, and you

By Jeff EatonArticle33 comments

Does Google's "duplicate content penalty" harm Drupal sites? No! Here's why.

For years, Drupal has enjoyed a solid reputation as a search engine friendly CMS. It generates relatively clean, standards-compliant HTML out of the box; syncs up the important TITLE tag with semantically useful H1 and H2 tags in the body of each page; and provides short, human-readable URLs with plentiful options for customization. (Anecdotal evidence: several years back, I wrote a post on my Drupal-powered blog that mentioned the name of the company I worked for. Within two weeks, my blog post ranked higher than the company's own web site on Google.)

Recently, I've witnessed a number of discussions where people expressed concern about the way Drupal generates the human-readable URLs that help make it Google-friendly. In particular, they were worried about Google's dreaded Duplicate Content Penalty, a system designed to keep spammers from flooding Google with the same content at dozens (or hundreds!) of URLs. There's a lot of confusion floating around, so for the geeks in the crowd (and the not-so-geeky interested in learning how things work behind the scenes), I thought it would be useful to give a guided tour of how Drupal manages and generates URLs. read more »

Avoiding the Template.php of Doom (or, Overriding Theme Functions in Modules)

By Jeff EatonArticle15 comments

Drupal's theming system offers developers and designers a flexible way to override default HTML output when specific portions of the page are rendered. Everything from the name of the currently logged in user to the HTML markup of the entire page can be customized by a plugin "theme".

Unfortunately, this system can be its own worst enemy. Themes are very powerful, but in many cases they're the only place where specific output can be changed without hacking core. Because of this, themes on highly customized production sites can easily turn into code-monsters, carrying the weight of making 'Drupal' look like 'My Awesome Site.'

This can make maintenance difficult, and it also makes sharing these tweaks with other Drupal developers tricky. In fact, some downloadable modules also come with instructions on how to modify a theme to 'complete' the module's work. Wouldn't it be great if certain re-usable theme overrides could be packaged up and distributed as part of any Drupal? As it turns out, that is possible. In this article, we'll be exploring two ways to do it: a tweaky, hacky approach for Drupal 5, and a clean and elegant approach that's only possible in Drupal 6. read more »

Modifying Forms in Drupal 5 and 6

By Addison BerryArticle162 comments

Drupal has a lot of forms to fill out and not all of them may be just the way you want or need them to be. Modifying forms is a topic that is often met with groans but once you understand the two methods to accomplish the task and the basic, underlying concepts, it really isn't that hard to do at all. You'll be a form-modifying, input-customizing wiz in no time. This article will briefly discuss what's going on and then mainly focus on showing working examples for both methods in Drupal 5 and 6. You should be comfortable creating a new function, looking at arrays and a having at least a passing understanding of the Forms API is real handy. Also note that in the examples below I have them wrapped in php tags but you should not include those if you copy/paste. That is just so it looks nice and clear for the article.

Deciding to make the change in the theme or a module

So there are two methods for altering form output in Drupal, one at the theme layer and the other through a custom module. Changes to the HTML can be accomplished with either method so most people will use the method they are more comfortable with already; themers use the theme and developers use a module. There are two situations however where you will want to use a module rather than a theme:

  1. Changing functionality of a form (e.g. adding new validation rules or submission actions) can only happen in a module.

Replace any string in Drupal (5/6), without Locale module

By Nate HaugArticle17 comments

During a recent Lullboat podcast we mentioned a new feature in Drupal 6 that allows you replace any string in Drupal without using Locale module (thanks Moshe!). Faithful podcast listener Rob Loach took it upon himself to write the String Overrides module that lets you accomplish this task with ease in Drupal 6.

While Lullabots were lamenting the fact that this feature was never in Drupal 5, we realized that it actually could be accomplished. An hour after undertaking the project, the patch was submitted to the String Overrides queue and committed shortly afterwards.

String Overrides accomplishes this in Drupal 5 by imitating the Locale module, and without hitting the database (since variables are cached and pulled up on every request anyway). Since this essentially a hack for Drupal 5, you cannot combine it with Locale module or languages other than English. Here's the key code that makes this possible: read more »

Using Macro Module to Move Content Type Changes Live

By Nate HaugVideo6 comments

Moving field changes from development to live doesn't have to be a stressful, error prone, and tedious process. Leveraging the macro module to test and package your field changes can make pushing changes painless. This video accompanies an article on the same topic: Moving CCK Field Changes from Dev to Live

Private forums in Drupal: Forum Access vs. Taxonomy Access vs. Taxonomy Access Control Lite

By Angie ByronArticle63 comments

Introduction

Most people who use forum systems such as vBulletin or PHPBB are used to having lots of extra features that Drupal core's forums don't contain by default, including private messages, smilies, and BBcode. While all of those are available as contributed modules, there are two "must-have" forum features that are a bit trickier, since they deal with access control: private forums, and forum moderators.

Drupal core tends to have an "all or nothing" approach to these issues. Either a particular role can access all content on the site, or they can access none of it. Either a particular role can administer all forums, or they can administer none of them. Luckily, though, Drupal provides a number of hooks so that contributed modules can add in their own robust access handling.

This article will look at three modules that enhance forum privileges, and compare and contrast them: Forum Access, Taxonomy Access Control, and Taxonomy Access Control Lite. read more »

Video: Upgrading from Drupal 4.7.x to Drupal 5.x

By Angie ByronVideo39 comments

This video walks you step by step through upgrading a Drupal site from 4.7.x to 5.x.

Watch the video (.mp4, 38MB)

Topics covered include:

  • how to evaluate your site to decide whether you should upgrade or not.
  • how to create backups of your database and files.
  • the preparation steps you should take prior to upgrading your site.
  • how to perform the upgrade itself, both of core Drupal and contributed modules.
  • some testing tips to help ensure the upgrade went smoothly.
  • where to find additional support should something go wrong.

Take control of your Drupal theme

By Matt WestgateArticle59 comments

Want to create a front page that's styled differently from the rest of your site? Perhaps you need a separate admin theme? Or how about a login page which only shows the login block and nothing else? With a little PHP knowledge these problems are easy to solve. read more »