Linux Journal - Drupal Special Edition 2012
Linux Journal - Drupal Special Edition 2012
SPONSORED BY
Since 1994: The Original Magazine of the Linux Community SPECIAL SUPPLEMENT | WWW.LINUXJOURNAL.COM
DRUPAL
PROVIDES
SOLUTIONS
TO REAL
BUSINESS
PROBLEMS
WHY DRUPAL
IS NOT A CMS
BUILD AND
DESIGN CUSTOM
CONTENT TYPES TREKK:
+
A Drupal
CREATE YOUR Solution for
OWN CUSTOMIZED Universities
DISTRIBUTION
CASE
OPEN ATRIUM: STUDY:
A FREE AND USENIX.orgs
FLEXIBLE PROJECT Migration to Drupal
MANAGEMENT TOOL And Much, Much More!
LJDrupalSupplement.indd 1 9/15/12 9:57 AM
CONTENTS SPECIAL
DRUPAL ISSUE
FROM THE EDITOR 52 Achieving Continuous
Integration with Drupal
6 DrupalIts Like Ice Cream, Everyone using Drupal needs to host
Only Better their site somewhere. However, most
Katherine Druckman people building sites with Drupal do not
also want to have to become experts
OPINION in building a reliable, scalable
infrastructure for hosting it.
8 Dont Pitch DrupalSell Solutions Barry Jaspan
to Real Business Problems
Consider one of the many flavors 64 RedHen CRMan Open-Source
of Drupal CRM Solution Built Entirely
Jeffrey A. McGuire with Drupal
Implement a native Drupal
FEATURES CRM solution.
Sean Larkin and Lev Tsypin
24 Drupal Is a Framework: Why
Everyone Needs to Understand This
Demystifying the Drupal hook system. DRUPAL MARKETPLACE GUIDE
Diana Montalion Dupuis 80 Gold, Silver and Bronze Sponsors
34 Drupal Distributions: Working
the Linux Model Up the Stack INDEPTH
Prepackaged distributions are 82 Speed Up Your Drupal
being heralded as a new era in Drupal Development Using
development. Learn how to make Installations and Distributions
your own one-click downloadable and How to create your own distribution
shareable Drupal distribution. of Drupal.
Forest Mars Oliver Davies
Building and designing custom content types is .epub, .mobi and an on-line digital edition,
as well as apps for iOS and Android devices.
easier now that a full Content Construction Kit is Renewing your subscription, changing your
e-mail address for issue delivery, paying your
built in to Drupal 7 core. invoice, viewing your account details or other
Dan Englander subscription inquiries can be done instantly
on-line: http://www.linuxjournal.com/subs.
E-mail us at subs@linuxjournal.com or reach
124 Tips for Writing Interoperable us via postal mail at Linux Journal, PO Box
980985, Houston, TX 77098 USA. Please
Drupal Distributions remember to include your complete name
and address when contacting us.
Expert tips on how to build Drupal distributions
and features that integrate cleanly on any site. ACCESSING THE DIGITAL ARCHIVE:
Your monthly download notifications
Nedjo Rogers will have links to the various formats
and to the digital archive. To access the
Techniques for boosting your Drupal LETTERS TO THE EDITOR: We welcome your
sites performance. letters and encourage you to submit them
at http://www.linuxjournal.com/contact or
Janez Urevc mail them to Linux Journal, PO Box 980985,
Houston, TX 77098 USA. Letters may be
160 Contributing to Drupal: Open for All! ADVERTISING: Linux Journal is a great
resource for readers and advertisers alike.
Contributing to Drupal is easy and rewarding. Request a media kit, view our current
editorial calendar and advertising due dates,
Kojo Idrissa
or learn more about other advertising
and marketing opportunities by visiting
us on-line: http://ww.linuxjournal.com/
advertising. Contact us directly for further
information: ads@linuxjournal.com or
LINUX JOURNAL (ISSN 1075-3583) is published monthly by Belltown Media, Inc., 2121 Sage Road, Ste. 310, +1 713-344-1956 ext. 2.
Houston, TX 77056 USA. Subscription rate is $29.50/year. Subscriptions start with the next issue.
Contributing Editors
Ibrahim Haddad Robert Love Zack Brown Dave Phillips Marco Fioretti Ludovic Marcotte
Paul Barry Paul McKenney Dave Taylor Dirk Elmendorf Justin Ryan
Advertising
E-MAIL: ads@linuxjournal.com
URL: www.linuxjournal.com/advertising
PHONE: +1 713-344-1956 ext. 2
Subscriptions
E-MAIL: subs@linuxjournal.com
URL: www.linuxjournal.com/subscribe
MAIL: PO Box 980985, Houston, TX 77098 USA
Go to http://drupalize.me and
get Drupalized today!
DrupalIts KATHERINE
DRUCKMAN
Open Atriums best featurethe customization custom content laid out just right using some
made possible by using open-source software. handy contributed modules and a little CSS.
Readers who have struggled with their For more-advanced developers, Nedjo Rogers
testing and deployment workflow will find has some tips on making Drupal distributions
some comfort in learning from the struggles interoperable, which will ensure long-term
of others. Barry Jaspan will help you follow flexibility and ease of expansion. Janez Urevc
continuous integration best practices with demystifies the Drupal cache system and shows
Drupal development, a potentially resource- and how to speed up performance, which is a
time-intensive task that can be made easier. universal struggle. Jody Hamilton, one of the
Continuing with the theme of showing off participating developers, gives an in-depth
the many flavors of Drupal, both new and look at the development behind the popular
old, be sure to take a look at RedHen CRM, a Open Source community site USENIX.org. And
relative newcomer. Offering a Drupal-native finally, Kojo Idrissa is your guide to the most
CRM solution, RedHen is worth checking out important and most frequently overlooked
if you are looking for a highly flexible and part of being a successful Drupaler,
customizable CRM experience, and Sean Larkin contributing to the Drupal community.
and Lev Tsypin are on hand to give you a tour. I hope after reading this special issue, youll
Busy developers will appreciate Oliver be as enthusiastic about working with Drupal
Davies tips on speeding up development as I am. As any Drupal user or developer will
with Drupal distributions. He explains how to tell you, Drupals flexibility allows for almost
automate some of the more repetitive tasks infinite possibilities, but also nearly infinite
a lot of developers struggle with. Then, Tim amounts of struggle. This issues aim is to
Loudon provides an in-depth look at the most help a lot with the latter and inspire much of
intriguing feature of the Trekk distribution, the former. Happy Drupaling!
which is aimed at Universities. Because many
universities struggle with combining legacy Katherine Druckman is an HTML-flinging, PHP-hacking
content from multiple sources, the team Linux Journal Webmistress by day and a refined connoisseur
behind Trekk developed Flatfish, an HTML of historic architecture and fine Chinese ceramics by night. She
scraping tool. Tim shows how it all works. usually can be found surrounded by the charm of aging Texas
For those who are newer to Drupal, some buildings from the pioneer days or appreciating ceramics of the
basic tasks can be very troublesome, but Song and Qing dynasties. Well, either that or sitting in a comfy
Danny Englanders tutorial on theming custom chair with a laptop. Yeah, probably the laptop thing. Now in her
content types will help a lot of beginners over sixth year heading all things LinuxJournal.com, Katherines
an initial hurdle. He walks through one of experiences in Web publishing for the open-source audience
Drupals best features and shows how to get have strengthened her stance as an impassioned Drupal fangirl.
Commerce Kickstart
E-COMMERCE
Commerce Kickstart is built on the Drupal
Commerce platform. Its an on-line shop in a box
(http://commerceguys.com/blog/just-released-
commerce-kickstart%E2%80%99s-first-beta),
giving you access to the growing e-commerce
market while saving you weeks of time configuring
the platform.
INTRANET
Open Atruim (http://openatrium.com) is an
intranet and team portal package. It comes with
a blog, wiki, calendar, to-do list, shoutbox and
dashboard to manage it all.
Acquia Commons
COLLABORATION
Acquia Commons (https://www.acquia.com/
products-services/drupal-commons-social-
business-software) is a ready-to-use solution
for building internal, external and cross-over
communities. It provides a complete social business
software solution for organizations to add the
social layer in the enterprise.
COD
OpenPublic
GOVERNMENT
OpenPublic (http://openpublicapp.com) is a
Drupal distro for government and policy groups.
Accessibility- and security-compliant out of the
box, it focuses on usability, transparency and
public participation needed in this day and age.
Julio
EDUCATION
Julio (http://julio.funnymonkey.com)
is a distribution targeted for schools, school
districts, small colleges and academic departments
within universities. It features calendars, clubs,
teams, announcements, departments, staff
directories and more.
Videola
MEDIA
Videola (http://videola.tv) is an enterprise-level
video management system and video delivery
platform. Create paid-access or free-access video
Web sites with an impressive range of tools for
organizing and managing video content, users and
e-commerce.
OpenPublish
PUBLISHING
OpenPublish is designed for the on-line news
industry (http://openpublishapp.com). It
contains a powerful suite of content, curation,
audience engagement and taxonomy tools to
build solutions for todays publishers.
SaaS
Theres quite a lot going on in the Drupal
Software as a Service (SaaS) area too.
Webform
Subhub
Drupal Gardens
Buzzr
potential and power as a tool-building Specialize! Hey, you know a lot about...
tool. Not every kid sees the castle, something! Maybe it's hotel management
spaceship or city in a giant tub of (http://drupal.org/project/rooms),
LEGO bricks. Instead of showing out- real estate (http://groups.drupal.org/
of-the-box Drupal and promising real-estate) or dentistry. Be the expert.
Theres a module for that, show Multiply all the value described above
them the picture on the LEGO box! by your own expertise. Build a Drupal
Drupal products look like what they product once; reuse it N times! This
do: Julio looks like a school Web site; is a great business model followed by
Drupal Commerce Kickstarter 2 looks many successful Drupal shops and other
like an on-line store. Reduce the businesses around the world, whether
amount of effort needed to visualize you sell services based on your distro
the final result, and you will reduce or simply want to accelerate your
the amount of convincing you need site-building business.
to do to turn a prospect into a happy,
Drupal-using customer. Dont pitch Drupal! Finally, Drupal
Go to https://acquia.com/instant-insight,
enter your URL, & get a free site scan
products allow you to avoid the biggest with solutions-based approaches. Red
mistake most Drupal business people Hat is a great example of thisdoing a
make: selling the Drupal value proposition billion dollars of business in 2011 with an
as if others cared about Drupal. You should open-source, solutions-based business.
help them understand the advantages of Take a look at this video:
an open-source CMS that has reached http://www.youtube.com/
critical mass resulting in innovation, risk watch?v=OJtQeMHGrgc. That was Steve
mitigation, cost reduction and future- Jobs in the very first Apple store before it
friendliness (http://www.lukew.com/ opened in 2001. Heres what he said:
ff/entry.asp?1407). But, putting it
bluntly, Drupal is just a means to an end, The center half of the store...
so: dont pitch Drupal; sell solutions to is devoted to solutions because
real business problems. people dont just want to buy
Just like Jim Whitehursts statement about that Drupal can fulfill their needs....
Linux mentioned earlier in this article, this Today, we have the best selection
inspired my thoughts about Drupal: of Drupal products, distros and
features that Ive ever seen, and
Our business is devoted to you can implement and customize
solutions because people dont just them to suit your needs.
want a CMS anymore, they want to
know what they can do with it, and Dont sell Drupal. Sell solutions to real
were going to show people exactly business problems.
that. Weve got four sections, the
Drupal solutions weve chosen to Jeffrey A. jam McGuire, Acquia Manager of Community Affairs,
feature for now are e-commerce, has a long-standing passion for Drupal and its community.
social business, government and He promotes and advocates for the Drupal project and
education (etc.)....You can show open-source software. Presenting around the world at Drupal
your prospective clients one or and other events helps satisfy his inner diva, which he also
more Drupal products, and they feeds with performances as a storyteller, singer, french horn
can just sit a spell, understanding and alphorn player. Tags: Musician, foodie, Drupalista....
Attend a Attend a
M
So Paulo - December 6-8, 2012 Dallas (09/07)
Sydney - February 6-9, 2013 San Diego - Higher Ed (10/11)
Y
CM
MY
Portland - May 20 - 24, 2013 Atlanta (10/26)
CY Prague - September 2013 Boston (11/15)
CMY
association.drupal.org/drupalcon DrupalSummit.com
DRUPAL
IS A
FRAMEWORK
WHY
EVERYONE
NEEDS TO
UNDERSTAND
THIS
Everyone planning and building
Web solutions with Drupal
benefits from understanding
what a hook isand
why Drupal is not a CMS.
DIANA MONTALION DUPUIS
Sometimes, these are easy questions usual workflow. In many cases, multiple
to answer. Many content-related tasks solutions exist, and choosing one involves
can be accomplished simply by logging in giving something up to get something
to Drupal, visiting the /admin page and else. As a developer or a stakeholder,
clicking on menu links until you land on finding the best solution that meets
the necessary administration page. business goals and stays in scope
More often though, there are depends upon cooperative discussions.
complicated questions to answer. Some That is where communication often
tasks can be accomplished by adding breaks down. Developers are speaking
contributed modules that easily plug in one language while site owners, project
to Drupal core, as it comes out of the and account managers, stakeholders
box, and expand a sites functionality. and others involved in the decision-
Contributed modules are created and making process speak another language.
When people first learn about Drupal, single text documents containing
their initiation often focuses on what everything you saw on the page, except
a node is, what blocks, content types for images, in one text file. The file
and views are, and how to create included HTML tags describing the
SEO-friendly URLs. These concepts are type of content being displayedfor
important, but they frequently fail to example, <p> denotes a paragraph,
answer the essential how hard is this and <h1> is a big headline. Browsers
to do question or provide a strong (which took ten hours to download)
foundation for collaborative planning translated this markup and presented
of more complex functionality. Everyone pages with a readable structure at a
involved needs to understand that they Web address dictated by the filename.
can architect a Drupal site that offers a The document would be uploaded to
more-sophisticated set of features than the server and saved in the Web sites
a WordPress site, because Drupal is not a primary folder. The filename page.html
content management system (CMS); it is then could be viewed using the browser
a content management framework. at yoursitename.com/page.html.
Conceptualizing Drupal as a framework If you wanted to change the Web pages
does not require years of programming content, you edited that file. If you wanted
experience; rather, it simply requires to change something in the header that
understanding what a hook is and appeared on all of the sites pages, you
finding out whether the one you need had to edit every page. Whether linking
exists and already is able to do the thing content together or displaying a similar
you want done. sidebar, content was laid out individually
To understand hooks, its necessary to on each and every page by hand.
understand how dynamic Web pages, Nowadays, most sites are dynamic.
delivered by Web applications, differ from Small programs, called Web applications,
static pages. Most tech-savvy people take are uploaded and stored on the server.
this knowledge for granted, especially Instead of delivering a static page to
Linux aficionados and those whose first view, the program runs when the browser
desktop computer had a flashing cursor at lands on the page, applying logic to
a C: prompt. But many people dont know the page creation process. This logic
how Web sites do what they do. (Why dictates how the page is built each time
would they?) Here is how I explain the a page is requested (also called on
difference in laymans terms. page load). For example: the program
In the olden days, static pages were gets the header, gets the main menu,
behind the scenes, provide responsive n Q: Who are you (specifically)? A: Start
pages or integrate front-end languages, a session.
scale to handle large traffic numbers by
making use of server technologies and n Q: What are your requirements?
provide the foundation for other as-yet- A: Create server/browser page headers
unthought-of innovations. (the parameters for further relating).
Heres where the process gets ingenious.
But, there is one more conceptual step n Q: Where are you?
to take before its clear that hard or easy A: Select language.
depends on hooksbootstrapping. Again,
this is a concept that may seem like Finally, Drupal delivers the content:
common knowledge to the tech-focused
reader, but it can be tongue-twisting to n Q: Which page? A: Serve up the page.
explain. Here is my laymans version,
which is an oversimplification, but a This is the sweet spot, the place
deeper understanding isnt a prerequisite where most (but not all) of the hook
to understanding hooks. magic happens.
When a browser hits a Web page, Hooks are little blocks of functionality,
Drupal asks a series of questions. The called functions, that contain PHP code.
question process is called bootstrapping. These blocks of code run when they are
The questions (Q) trigger actions (A). called upon. During the bootstrapping
process, especially when the final which
n Q: Who are you (generally) and what page? question is asked, hooks are
do you want? A: Initialize and store called. Whenever an event happens in
general info. Drupal, like deleting a page, hooks are
called. Inside those hooks, there is code
n Q: Can I just give you a stored copy? that alters functionality, and it runs
A: Serve cached data (content stored as soon as the hook is called. Almost
in memory). anything you want Drupal to do has a
hook doing it.
n Q: Can I connect to the database? Drupal relies on naming conventions
A: Do so or die. to call hooks when the time is right for
them to run. While building the menu,
n Q: Do I need anything from there to Drupal looks for hooks with _menu in
work? A: Get it. the name. When a page is deleted, hooks
hook is called. What your site will do releases, blog posts and so on. An admin
with the data and the load it puts interface in Drupal 7 makes creating
on the system greatly influences the nodes (the foundational content type
complexity as well. with a title and body) and adding fields
of related data to them, like the author
n Your tasks cant run on page load, a and publisher in a book review, a code-
special process has to be written to free task. Creating book reviews that
accomplish them. Sometimes, this is include a cover image, author, publisher,
a quick addition (a simple cron job publication date and a link to Powells
using hook_cron), and sometimes this City of Books is quick. Adding a five-star
is complicated. Often, this approach rating to each review involves adding one
is used when data processing would contributed module and turning it on.
slow page load down (or take down How hard it is to make the review
the site), so it is handled out of look like the design depends on how
sync and saved (cached), serving the much the design varies from the way
cached version when the page loads Drupal presents the content to the page.
and the question is asked. If the author, publisher and so on will
be displayed in the order it was created
Does Drupal already include the administratively and styled according to
necessary hooks running the necessary the sites general style guide, creating
code and does it provide an admin the look and feel involves adding some
interface to set up what you want to CSS to the themes CSS file(s). Easy! But
accomplish? Easy! Do you need to get if the page will distribute the fields in a
mega-amounts of data from elsewhere, unique order or include custom behavior
process and save it out of sync with page (like also displaying other books the
load, and create new database tables user has rated), custom work needs to
that interact with existing data? Hard! be done. Hooks in the modules and in
Drupal core and many contributed the theme enable this work to happen,
modules are primarily designed to allowing the page load process to be
manage content, to power a CMS interrupted and edited.
which is why it is right to say, from one Ironically, the fact that Drupal enables
point of view, that Drupal is a CMS. Out the creation of a book review content
of the box, users can create any content type is also what makes it a framework.
type imaginablebook reviews, recipes, In the words of Larry Garfield, Drupal
scholarly paper submissions, press core contributor and member of the
Diving into the syntax of hooks does spit out all of the content in one big blob.
require programming knowledge and is, The primary tools to build information
in my experience, where the discussion architecture are content types, menus,
between developers and product owners blocks, taxonomies and views.
should end. My developer cohorts
and I discuss the technical aspects of n Nodes, content types and fields give
implementing hooks: which to use, structure to the content. Fields (like
where to put them, when to call them, author or publisher) make for easy
how to simplify the code they run, content creation and visual continuity
performance issues and caching plans, for the user.
the decision to use contributed code or
write my own. Once the decision to, for n Menus enable navigation by creating
example, pull in feeds and display them a structure of associations. Menus
is made, the how discussions begin. create a content geography and reveal
(Node.js anyone?) Communicating the the paths for exploring it without
issues that arise as the how is being getting lost.
n Blocks are boxes of content that can alphabetically. The lists often are
be associated with and displayed created using the Views administrative
in a region, such as the sidebar or interface, but custom code can
footer. These boxes can be filled override the output (hooks!), and
with any kind of content: nodes entire views can be created in code.
and content types, menus, lists, text
with markup, output like feeds or The Drupal framework is a kitchen
unique code-created lists like most where, yes, there already are tools
recommended. There are hooks, of in the drawer and ingredients in the
course, to create, control, edit and pantry. But those tools and ingredients
override blocks, although most blocks do not define the meals that can be
are built administratively. made there. Teams of site owners,
stakeholders, project managers,
n Taxonomies are lists of terms that business-goal definers and developers
can be associated with content. Most can cook better meals together when
users are familiar with the idea of Drupal is understood as a framework.
tagging, associating a blog post Approaching Drupal as a CMS often
(for example) with a list of terms like means bending it to your will: I want
coding, biking, cooking or hiking zucchini muffins like my mother used
In Drupal, taxonomies can provide to make; do that. As a framework,
the foundation for more-complex use Drupal encourages creating the best,
cases, but associating content is the most-elegant recipe within the scope of
most common. the endeavor: Heres some zucchini,
what can we do with this?
n The Views module is a list-maker, Drupals flexibility may make answering
powered by a contributed module. our three questions (how long, how
Many complex tasks can be handled much and can it be done) more time
by Views, but at its most basic, its consuming. But in the end, the outcome
the way to create a list of content is far more satisfying.
in Drupalfor example, all book
reviews posted in the last three Diana Montalion Dupuis is a software developer, Web
months. Views also can display strategist, writer, trainer and hiker who doesnt spend
content using associations, such as enough time in the mountains. She lives in Austin, Texas,
all posts tagged with the taxonomy where it is too hot in the summer, and is Director of
terms apple and spinach, sorted Development and Professional Services at Four Kitchens.
In-depth information
providing a full 360-
degree look at featured
topics relating to Linux
Tools, tips and tricks you
will use today as well as
relevant information for
the future
Advice and inspiration for
getting the most out of
your Linux system
Instructional how-tos will
save you time and money
Subscribe now for instant access!
For only $29.50 per yearless
than $2.50 per issueyoull have
access to Linux Journal each
month as a PDF, in ePub & Kindle
formats, on-line and through our
Android & iOS apps. Wherever you
go, Linux Journal goes with you.
DRUPAL
DISTRIBUTIONS
Working the Linux
Model Up the Stack
The ability to download and run a complete Drupal application
easily is being heralded as a new era that is completely
transforming how people use Drupaland the Web. In this
article, I discuss how Drupal distributions are made,
how you can use them, and how to add your own
distribution to drupal.org.
FOREST MARS
users and to allow it to be used to meet was more like a formula than a
their needs without all the unnecessary completed thing. It included a list of
complication. sub-components that would be needed
CivicSpace was one of the very first in addition to Drupal core (which
distributions, although it wasnt wasnt itself even included), such as
necessarily a distribution in the specific modules, themes and a profile file that
sense in which the term is used in contained scripts required to execute
Drupal today. Aimed primarily at political predefined functions and configure the
campaigns, it was the one that started completed site.
it all, demonstrating how the Drupal Building an installation profile
CMS could be used to build an easily required considerable knowledge of
expanded, complex distributed network Drupal APIs and a fair amount of time
where to get them, how to get them and that allowed you to use Drupal to do
even what patches need to be applied. something that wasnt strictly possible
Just a few short months after the with vanilla core: running it on a reverse
first version of drush make was released proxy server to be able to scale site
in mid-2009, it was used to create a performance. This advancement ushered
Drupal distribution called Managing in a whole new era of highly performant
News, which prior to that had been Drupal sites able to serve up content at
a downloadable package, but was Web scale, and was later included by
not based on any universal package default in Drupal 7.
management framework. With the Pressflow also diverged in the sense
adoption of drush, it became the first of being a completely packaged Drupal
install profile to include a makefile. This install containing all components, as
was somewhat of a watershed moment opposed to a manifest that you had to
for Drupal, as it was the first Drupal build with drush, anticipating the Drupal
installation profile that automated the distribution era. A full distribution
build process, instead of requiring you doesnt need anything to be fetched
to go fetch all the components yourself. over the network but includes all
After this, the genie was out of the components in a single bundle, vastly
bottle. Drush make allowed installation simplifying the process of circulating
profiles to be assembled and served finished Drupal sites with complex
up as a single downloadable tarball, sophisticated functionality.
instead of requiring the user to go fetch
all the pieces individually from different Distributions on Drupal.org
locations and put them all together. In December 2009, drupal.org updated
The next important milestone was its infrastructure to integrate the drush
Pressflow, which wasnt technically a make tool as a packaging system (in
distribution, or even an profile, but large part due to the work of Derek
a retooling of Drupal 6 to make its Wright). Up until that point, there were
HTTP headers compatible with the no distributions on the main site, but
Varnish reverse proxy server. Pressflow only installation profiles. The integration
was important in that it wasnt just of drush make turned drupal.org into
a collection of Drupal features aimed an on-line package management system
at a specific interest group (in fact, it that automated the process of turning
included no bundled modules at all) a Drupal site manifest into a finished
but was purely a technical distribution Drupal tarball ready for download.
full copy of Drupal packaged together Drupal distributions improve the factory
with the additional modules, themes model when you need to able to spin
and scripts that give you everything you up or deliver Drupal solutions quickly
need to produce a complete and complex and efficiently, and like the original
Drupal Web site in a single downloadable installation profiles that gave rise to
file. Its a ready-made tarball (or zip) them, they are especially effective at
thats completely self-contained. meeting a widespread use case (just as
they are much more efficient at meeting
The Distribution Advantage it). Essentially, distributions finally realize
The now outmoded method of assembling the vision of install profiles both in terms
all these components manually was a of vastly improving the Drupal experience
tedious process and one that required and facilitating an ecosystem now heavily
you to know a good bit about Drupals populated with hundreds of distros of every
terminology and file structure, not to stripe and color, such as the Spark distro,
mention having to implement all the which brings in-place editing to WYSIWYG
required function calls yourself. The process content management; Open Atrium, an
was repetitive and predictable, which made extremely popular groupware/intranet
it a great target for automation. In addition (the Whitehouse uses it as an internal
to the main benefit of automation and ease, collaboration tool); DataPublic, for creating
distributions can provide: open data portals; a paste-bin distro; a
port of Joomla called GLORilla; and the
n Increased development speed. official TedX Web site, just to mention a
few of the hundreds of freely available
n A clean way to install your site and be distros, from educational to corporative,
able to hand it off to others. from scientific to religious, all of which
can be downloaded directly from
n The increased ability to compete with http://drupal.org/project/distributions.
commercial turnkey solutions. Note, however, that Drupal doesnt
have a defined way to separate upstream
n An ecology that encourages and local configuration and settings.
collaborative development and Theres no /usr/local, and apart from
community involvement. workflow-based solutions, its a missing
piece that arguably would be of great
n A platform to invent new markets benefit to making Drupal distributions
heretofore unthought of. even better.
repository to download them from, such as (Note: this step can take several minutes
GitHub. (You also can use a repository other depending on the size of your site.)
than drupal.org for contrib modules, such At the completion of this step, you will
as running your own local repository to have a finished Drupal distribution that
speed up package retrieval.) The easiest way anyone can use to spin up an instance
to generate the basic site manifest is to use: of the kind of Drupal site youve built,
without downloading anything additional
$ drush make-generate my-site-name.make over the Internet. You could offer it for
download at the site of your choosing,
which will auto-generate the drush or you could put it on a site specifically
makefile based on your current site dedicated to showing off your distribution
configuration. For any information it cant and making it available for download.
find (the path to a custom repository, for You even could add your custom distro
example, which isnt stored anywhere else to the growing number available for
in configuration), it will insert placeholders download directly from the drupal.org
reminding you to fill this in manually. And, Web site. However, to do this, you wont
of course, if youre using alternate or dev submit a full package made with the
versions of any contrib modules, they will prepare-install command, but instead
be included too. Inspect the file it created generate the makefile only:
for you and make sure any placeholders are
replaced with corrected paths. (Covering $ drush make --generate-makefile drupal-org.make
MAKING
OPEN ATRIUM
YOURS
Open Atrium provides organizations and individuals with a free,
robust and flexible project management toolone that
demonstrates just how powerful and beautiful Drupal can be.
PATRICK SETTLE
OPEN ATRIUM is packed full of features right out of the box: a calendar,
discussions, a notebook for project documentation and a flexible task manager. Even
with hundreds of thousands of Open Atrium installs, its most powerful feature is
often never taken advantage of: Open Atrium is an open-source project.
Although people know what open source means, they dont take advantage of
this feature enough, even though it is one of the best features any project could
have. This feature empowers you to do so much more, but it doesnt mean that you
need to be a hard-core developer to participate.
Lets explore some very real examples of the benefits of Open Atriums open-source
feature and look at how you can take advantage of this underutilized facet to make
Open Atrium your own.
Sub-themes allow you to use an existing description = "A Ginkgo sub-theme to get work done,
engine = "phptemplate"
Open Atrium
A good example of a sub-theme for stylesheets[screen][] = "style.css"
Blocks or boxes Show or hide Modify the context that sets the block as visible or
hidden (see the section on contexts).
Menu items Modify menu attributes like Use hook_menu_alter() in a custom module.
path or remove an item
CCK fields Add a new field to an Add the new field, and then create a new feature
existing content type module that includes this field. The exported field
will contain information that associates it with the
content type.
immediate, ready or not. Once you make production server. Someone has to write
that change, its live. There is no chance down every configuration change that
to coordinate other related changes. In was made, and then on production,
addition, all users with access can make walk back through each change. Second,
a change, even if they didnt mean to theres no way to know what state the
make the change. It doesnt require site is in, so did those changes get made?
programming, which means its not in Theres only one way to checkload each
code. This could lead to a couple major configuration page and look.
issues. First, its difficult to deploy to a Its also important to note that if
Y
Our masks are off -
n Version control: make rollbacks more CM
revealing beautiful sites
granular instead of rolling back the MY inside and out.
entire database. CY
CMY
Easy on the eyes,
easy to use.
K
Achieving
CONTINUOUS
INTEGRATION
with Drupal
Drupal developers want to follow best practices in software
development, testing and deployment, known as Continuous
Integration. However, they often do not have the time, resources
or management support to invest in the necessary infrastructure.
BARRY JASPAN
I
n the early 1990s, my first job out of call the Waterfall method. We thought
college was as a software engineer at we were invincible.
a startup company. We were building We had no idea what was coming.
a commercial product using a well-known After consultation with potential
open-source network security project. In customers, we wrote a Requirements
those days, Agile software development document describing what the product
practices (not to mention the World needed to do, a Functional Specification
Wide Web, or even widespread public that described how the product would
awareness of the Internet) still were in look and behave, a Design document
the future. My fellow engineers on that that described the technical architecture
project (who had just graduated with me and internals of how we would build
and to this day are the best programmers it, and even a Test Plan that described
I know) and I were taught what we now the automated tests we would build
2. Make small, frequent changes. All 6. Have an audit trail (that is, a blame
developers should commit their list). This helps you not just in the
changes frequently. This reduces the source control of who made this
inevitable conflicts and lets problems commit, but who deployed the
surface sooner. Also, small, frequent commit as well. This can provide
changes enable small, frequent rationale as well as potential fixes.
releases, making all the rest of the
principles more valuable. 7. Automate site deployment. In order
to tolerate small, frequent releases,
3. Automate testing. Have your pushing a release needs to be an
repository automatically integrated automated process so its very quick
with a testing environment, so that and easy. If its a big chore to push one
every commit triggers a test run. release, the whole process falls apart.
This way, you know immediately if
something broke. 8. Measure results and iterate rapidly.
Are the changes helping? Is the site
4. Test in a clone of the production faster? Did the usability enhancement
environment. It does no good to yield more sales? If its not, you can
test your software under different iterate again.
conditions from those that it will
run in production; doing so is a Achieving Continuous Integration
recipe for taking down your site requires some amount of infrastructure,
when you deploy. Never hear the culture and discipline of the
someone say But it worked on engineering team to use it, and
my machine! again. managements understanding and
commitment so that it supports the
5. Make all versions easily accessible. necessary investment. This is an article
Despite best efforts, production about technology, not management
releases still will break, so you and culture, so I focus primarily on the
need an easy way to re-deploy a infrastructure here.
prior version. Then, youll want to
compare the working and broken Building It Yourself
versions to figure out what went Many shops build their own CI systems
wrong. To do this, youll need a that are perfectly tailored to their own
reference copy of past releases. needs. Doing so is perfectly reasonable
Here are some of the things you should you will want to run them every time
keep in mind. someone makes what they believe is
Use a source code repository. You a release-ready commit. Lots of tools
probably already are (right?). You will exist for doing this. One popular choice
need to be familiar with its post-commit is Jenkins (formerly called Hudson), and
hook capability to script actions based it is excellent. It can integrate directly
on it. If you are using a hosted repository with your code repository and trigger a
(such as GitHub), you will have to job on every commit, or run a job on
integrate with its Web-based hooks. a schedule.
Make small, frequent changes. All of The tests themselves are not the whole
your developers will be making frequent story though. Because your application
commits, resolving conflicts locally as is a Drupal site, you need to test it in a
best they can. To keep things moving Web environment. Youll certainly need
forward, you need to have a constantly a running database server. If you want
to test actual page loads like a browser your test environment as it is your
would see, youll need a running Web production environment.
server too. You probably want to test Where do you run all this stuff?
your application along with a reasonably The simple answer is to run it on
current production database; if you the same server as Jenkins. However,
dont automate that, one day youll Jenkins probably is not running on your
find yourself testing against year-old production servers, so immediately
data. However, you also probably want your test environment is different from
to scrub your current production production. Do you know that when you
database before running tests against install Jenkins via your distros package
it, lest you accidentally spam all your manager that it does not pull in some
customers from your test servers, or other package that your site might end
worse. This is all the responsibility of up using in testing but then fail because
your test harness script, run by Jenkins. it is missing in production?
If you fool yourself that you can This points to an even deeper issue.
mock out these dependencies and You cannot create a clone of your
have purely standalone unit tests that production environment unless you
can run anywhere, reality will mock know exactly what your production
you back. You will discover that tests environment really is. What packages
are not accurately simulating your live are installed? What configuration
environment, and you will have to roll files are in place? What dmons are
back a release that passed all of its running? What security updates have
tests but failed in production. been installed? Running a production
Test in a clone of the production Web site leads to all kinds of unexpected
environment. This is where things really issues and surprises, and even the best-
get interesting. Ive already talked about intentioned, well-meaning sysadmins are
needing a running Web and database likely to solve a crisis by changing some
server. If your site uses additional services configuration on the server by hand. You
like memcached, Varnish or Apache Solr, have to make sure those changes always
you need to make sure those are in place get propagated to your test environment.
too. If your production site uses SSL, you For that matter, you have to make sure
either need SSL running in your testing they are permanently maintained in your
environment, or you need to turn off the production environment too.
checks or redirection that enforces it. This leads directly to the topic of
Ultimately, it is as much work to maintain DevOps and server configuration
new application to the live environment. have lunch five minutes later without
If youve automated your infrastructure worrying about it.
as described and already have a system Measure results and iterate rapidly.
in place for deploying new code commits There are many great monitoring and
to your testing environment, this should measurement tools available that check
be a pretty small additional step. It has for things, such as error logs, page
to be simple, fast and reliable; you want load performance, server performance,
to be able to push a release and go A/B testing and more. Because
Figure 2. The Code selector lets you deploy any branch or prior release version to
any environment.
let me quickly demonstrate how Acquia for initial integration testing. Set it to
Cloud provides everything you need to deploy the master (Git) or trunk
implement CI for your Web site. (SVN) branch, and every developers
Use a source code repository. Acquia commits are available immediately for
Cloud provides both Git and SVN initial experimentation.
repositories. The URL is displayed right Automate testing. Every time you
at the top. deploy code or perform various other
Make small, frequent changes. actions, Acquia Cloud runs Cloud
Acquia Cloud provides a development, Hooks. These are simple scripts that
staging and production environment for you put into your code repository to
your site. You can deploy any branch perform any actions you want. Each
or tag from your repository in any of hook is tied to specific actions in a
them. When you deploy a branch in specific environmentfor example, all
an environment, every commit to that scripts in the hooks/post-code-deploy/
branch is deployed to that environment. prod directory of your repository
This makes the Dev environment perfect run when you deploy code to the
Figure 3. The Task log shows all changes to any of your sites environments.
Figure 5. Deploying code is a simple drag-and-drop operation (API and CLI also
available).
To view a video overview that showcases ago!). Currently Senior Architect at Acquia, he leads Acquia
how to develop with Acquia Cloud for your Cloud, the Drupal-optimized PHP cloud hosting platform that
Drupal site, I have a Webinar on this very runs tens of thousands of Drupal Web sites on thousands of
topic available at http://ow.ly/cUNlL. cloud-based servers for some of the best-known brands in
To sign up for a completely free the world. He is an angel investor and advisor to Boston-area
version of Acquia Cloud, visit startups and, when he pulls himself away from the keyboard,
http://network.acquia.com/freecloud. an avid whitewater kayaker and rock climber.
RedHen CRM
an Open-Source
CRM Solution Built
Entirely with Drupal
Historically difficult to implement in Drupal, native CRM
solutions in Drupal 7 now allow site builders to craft more
personalized user experiences for their Web site visitors by
integrating their Drupal CMS with their customer relationship
management system (CRM). SEAN LARKIN and LEV TSYPIN
create instances of these entity types. and machine name. Create one for
That is because, out of the box, RedHen Staff and Volunteers.
doesnt presume to know the types of
contacts, organization, memberships and n Organizations: aside from machine
so on, that will be needed for a given name and label, organization bundles
CRM deployment. In Drupal speak, these can be turned into content groups
entity type instances are called bundles. if the redhen_org_group module is
In the next step, you will define bundles enabled. Checking the groupify
for each of your RedHen entity types. box exposes two additional settings:
First, navigate to /admin/structure/ private and a list of content types
redhen to see the types of entities that that can be posted into the group.
can be managed through RedHen. They Create two organizations, Foundation
are, again, contacts, engagement scores, and Shelter, making the latter a
memberships, notes and organizations. content group.
For each of them, create the following
bundles, respectively: n Notes: notes come with a default
single bundle since there is only one
n Contacts: contacts have only a label type of note.
target entities and directionality of the the Entity API interfaces still needs
relation. For the sake of this demo, lets to clarify the data types of all entity
stick with the default relation types. properties and provide Views handlers
for any nonstandard data. For
Playing Well in the Drupal Sandbox example, organization entities have
RedHens default listings of contacts a primary contact associated with
are a good start, but the fun really them, and its up to RedHen to explain
starts if you want to create your own to Views that the related contact
custom views. The venerable Views ID within an organization record is
module, a powerful graphical query actually a RedHen contact. Lets create
builder, is the gold standard in Drupal a new View, adding additional fields
for creating custom lists of stuff, and relationships to the standard list
including RedHen entities. Much of of contacts:
the heavy lifting involved in Views
integration is handled by the Entity 1. Create a new view at /admin/
API, but any module implementing structure/views/add of Contacts.
if ($contact->redhen_state == REDHEN_STATE_ACTIVE) { )
return FALSE; );
} }
$render['table'] = array(
);
function mytheme_redhen_contact_list($variables) { }
'#markup' => t('Sorry, there are no contacts much more affordable and nimble than
that match your criteria.'), trying to develop comparable features
); upon larger, more cumbersome
} enterprise packages.
return render($render); Sean Larkin has more than ten years of diverse leadership and
} technical consulting experience. He has been working with the
best and brightest software engineers and designers in the
In short, using RedHens comprehensive Drupal community for the past five years. He has led national
APIs, hooks and theme wrappers, a community organizing initiatives and international relief
developer can build a complex, elegant projects, served as a fundraising strategist for environmental
solution to meet nearly any use case groups worldwide, and ran two open-source software
requiring CRM functionality. consultancies specializing in Drupal development. He holds a
Master of Public Administration (MPA) degree from Syracuse
Conclusion Universitys Maxwell School. Outside work, Sean is an avid
Although we think its possible to build whitewater enthusiast, certified kayaking instructor, raft
very robust, large-scale CRM solutions guide and whitewater videographer. He has been a longtime
natively in Drupal, ThinkShouts goal in advocate and supporter of river conservation organizations,
releasing RedHen CRM is not to compete such as River Network and Waterkeeper Alliance.
with the enterprise CRM market.
Platforms like Salesforce almost inevitably Lev Tsypin has more than 12 years of experience leading
will out-scale any CRM solution that we technology projects and is a technical architect and
can build with Drupal. co-owner of ThinkShout, Inc., where he leads technical
That said, enterprise CRM solutions design, user interface and module development. Prior to
often are overkill for small to mid- ThinkShout, Lev ran the highly respected consultancy, Level
size organizations and businesses. Online Strategy. In the 1990s, he worked as a consultant
Moreover, even if your organization with Computer Sciences Corporation (CSC) and Inforte
does need an enterprise CRM solution, Corporation in Chicago. Before starting Level OS, he served
we see RedHen as a natural integration as the Director of Programming at Pop Art, Inc. He holds
point between your Web site and such a Bachelors degree in Business Administration (BBA) and
a system. RedHen CRM opens the door Political Science from the University of Wisconsin-Madison.
to the creation of highly innovative When not working to help organizations through technology,
front-end CRM tools. We anticipate Lev likes to take advantage of the areas they protect, be it on
that collecting and displaying data foot, skis or bikeat least when hes not wrapped up with
in RedHen (and Drupal) often will be his two boys, which isnt very often these days!
RedHen CRM Source Code, Project Page and Issue Queue: http://drupal.org/project/redhen
(RedHen CRM download and usage statistics can be found here as well.)
Drupal Commerce, the Leading Drupal E-commerce Package with Which RedHen Integrates:
http://drupal.org/project/commerce
Linux JournaL
now available
for the iPad and
iPhone at the
App Store.
linuxjournal.com/ios
For more information about advertising opportunities within Linux Journal iPhone, iPad and
Android apps, contact Rebecca Cassity at +1-713-344-1956 x2 or ads@linuxjournal.com.
GOLD SPONSOR
New Relic:
A developer's best friend
to monitor end-to-end
performance of your PHP app.
http://www.newrelic.com
SILVER SPONSOR
Acquia
https://www.acquia.com
Acquia empowers enterprises with the open source
social publishing system Drupal. Co-founded by Drupals creator in 2007, Acquia helps customers manage their
growth and scale their online properties with confidence. Acquias products, cloud infrastructure, and support
enable companies to realize the full power of Drupal while minimizing risk, as its done for more than 2,400
enterprise customers including Twitter, Warner Music Group, Turner Sports, World Economic Forum, Stanford
University, Mercedes-Benz and NPR. See whos using Drupal at http://www.drupalshowcase.com, and for more
information please visit www.acquia.com or call 888-9-ACQUIA. p. 21
SILVER SPONSOR
Aten Design Group
http://atendesigngroup.com
Aten Design Group is a web strategy, design, and development company based
in Denver, Colorado.
We are Drupal experts and open source contributors. We design, build and support websites for organizations
doing good work all around the world. We're passionate about meaningful user experience, beautiful design, and elegant
open source solutions. Since 2000, weve worked with journalists, educators, human rights activists, health-care providers,
climate change adaptation experts, international aid workersa broad range of organizations committed to making positive
changes in the worldto build interactive platforms that help impact lives.
We provide comprehensive strategy, design and development services to run all aspects of successful interactive
projects, from start to finish. Our services include content strategy, information architecture, technical planning, design,
development, support, dev-ops and server management. p. 43
BRONZE SPONSORS
Elevated Third http://www.elevatedthird.com
Founded in 2005, Elevated Third is a leading digital agency in Denver, Colorado. Through its unique combination of user-centered
creative and open-source technology, Elevated Third is recognized for its digital marketing solutions that integrate intuitive user
experience design using Drupal. The agency provides a variety of other award-winning services, including branding and usability
and SEO consulting. For more information, visit elevatedthird.com, the company's Facebook page, or follow @elevatedthird. p. 51
Advertiser Index
ADVERTISER URL PAGE #
Do you find yourself repeating the same in this article has been committed into
steps whenever you start a new Drupal GitHub at https://github.com/opdavies/
project? Do you always download and linuxjournal_demo, and its available for
enable the same modules, and make the you to download and re-use as needed.
same configuration changes every time?
As we start doing more and more Drupal What Are Installation Profiles?
projects at Nomensa, I noticed that we Installation profiles are a combination
were doing exactly this, so I started to of modules and themes and predefined
look into ways to streamline our initial configuration. A great example of an
project setup process. My solution was to installation profile that I use regularly is called
create my own custom installation profile Commerce Kickstart (http://drupal.org/
that provides me with a template to start project/commerce_kickstart). It provides
each project, and this article outlines the a version of Drupal 7 along with the
steps I took to create it. The code outlined Drupal Commerce suite of modules that
either using a drush command like your installation profile. Mine is called
drush dl commerce_kickstart, or linuxjournal_profile, although the name
clone it directly from its Git repository, of the profile is going to be simply
and then place it within the Drupal's linuxjournal. Ive appended _profile to the
profiles directory. end of the directory name. Later, there
Now, when you go to install Drupal, will be several different directories with
there is an additional option to use similar names, so this helps provide some
the Commerce Kickstart installation clarity. Be sure to give some thought to
profile. Select the appropriate profile, the name beforehand and ensure that
click the Save and continue button, it doesnt conflict with any potential
and continue through the installation modules or themes.
process as normal. The first file I need to create is the
linuxjournal.info file that, identical to
How to Start Creating Your Own .info files for modules and themes,
Installation Profile defines the name and description of the
Outside your Drupal directory, create profile, as well as which version of Drupal
a new directory to hold the files for core that it is compatible with. Im also
Figure 3. The Install Screen with the Linux Journal Installation Profile
going to make it dependent on the core take effect during the installation process.
dblog and block modules so that these For now, Im just going to add an opening
are enabled automatically when the PHP tag and leave the rest of the file blank.
profile is installed: To confirm that everything works okay so
far, I can download a fresh copy of Drupal
name = Linux Journal core, copy linuxjournal_profile into the
description = A demonstration installation profile for my LJ article. profiles directory, rename it to linuxjournal
core = 7.x so that it is the same as the name of the
dependencies[] = dblog profile, and load that site in a Web browser.
dependencies[] = block So far, so good. On the installation
page, as well as seeing the default
The only other mandatory file Standard and Minimal profiles, I also can
needed for this profile to be visible to see my Linux Journal profile. I can select
Drupal is the .profile filein this case, this and continue with the installation
linuxjournal.profile. Within this file, I process as normal to confirm that its
can put any custom PHP functions or working, although because Ive not
implementations of Drupal hooks that will entered anything into linuxjournal.profile
*/ api = 2
core = 7.x
/**
for most of my themes, Ill include * Allows the profile to alter the site configuration form.
$form_state) {
projects[omega][download][type] = git }
projects[omega][download][url] =
of hook_form_FORM_ID_alter() into * Allows the profile to alter the site configuration form.
ID of the form is install_configure_form, // Set a default site name and email address.
$form['site_information']['site_mail']['#default_value']
$form['update_notifications']['update_status_module']
$form['admin_account']['account']['name']['#default_value'] }
= 'Oliver Davies';
$types = array(
themes. The first thing I want to do 'description' => st("Use <em>basic pages</em> for
next is use the Seven theme for the your static content, such as an 'About us' page."),
function in linuxjournal.install: }
// Enable the administration theme. // Default 'Basic page' to not be promoted and don't
->condition('type', 'theme')
->condition('name', $admin_theme) To create additional content types,
->execute(); I can keep adding new items into the
variable_set('admin_theme', $admin_theme); $types array, and they will be processed
variable_set('node_admin_theme', '1'); within the foreach() loop.
libraries[tinymce][download][type] = get
http://git.drupal.org/project/wysiwyg.git // Add the TinyMCE editor to the Filtered HTML text format.
'italic' => 1, );
'strikethrough' => 1,
'numlist' => 1, );
'link' => 1,
'image' => 1,
requires creating some additional roles for foreach ($roles as $weight => $name) {
users who can edit and publish content. I $role = new stdClass;
by any of the other Developers in the team $role->weight = $weight + 2, // New roles must have at
install and use that as a template: // Give the Developer role all permissions.
user_role_grant_permissions($role->rid,
Trekka Drupal
Distribution for
Universities
Take a close look at how Trekk uses Flatfish to scrape and
share content.
TIM LOUDON
When I talk about sharing content unique requirements. The Trekk client
across sites, I really mean more than that. is robust and uses Migrate under the
If you just wanted to display some simple hood to create the Drupal nodes. There
content on two or more sites, you could is the added benefit of controlled
do that using Drupal core and standard updates and access to the Migrate
contrib. The Views module could provide plugin ecosystem. And, returning to the
an outbound RSS feed, and the other Views+Feeds comparison, Trekk preserves
site(s) could use Feeds to consume the relationships. If theres a Faculty content
content. This architecture falls down type and a Publication content type, the
though when you have complex data connections between the nodes on the
and/or what I would call a real-world server are passed on to the clients.
workflow. Trekk conceptually builds on As for Flatfish, youre probably
this Views+Feeds approach to create a wondering, Why would a PHP Drupal
lightweight content server. A Trekk server developer create a tool in Ruby? When
uses Views and Services to expose JSON I initially designed Flatfish, I knew that I
endpoints. Trekk clients then can access wanted something flexible, dynamic and,
the server securely and get the content honestly, a bit magical (but hopefully
they need. not cryptic). Ruby seemed like an ideal
Additionally, Trekk clients can choice, but two libraries made it the
manipulate the data into multiple only one: Nokogiri and Active Record.
formats. For example, a client site can Nokogiri is an awesomely cool Ruby
consume the JSON and create Drupal gem that provides CSS selectors as well
nodes. This lets the client site control as XPath for XHTML and XML. The end
the display through the use of Views, result is fine-grained control over what
Display Suite or Panels. You also could HTML gets scraped. This has worked out
write a simple extension to the Trekk surprisingly well, even on pure HTML
Server to share HTML, and then client sites where there arent CMS templates
sites could show this directly via Panels. to force all the desired content into
It allows for a tremendous amount of the div#main or div#content. The other
flexibility in how the client sites use the library, Active Record, is one of Ruby
shared content. This is key in helping on Rails core libraries. It provides an
school and department sites maintain ORM, so all persistent data manipulation
their autonomy, but it also allows for in Flatfish is done via Objects. This
better brand compliance and centralized has been incredibly handy, as Flatfish
control where appropriate. Trekk allows creates database tables on the fly
you to build a system that meets your and adapts those tables to mirror the
destination Drupal systems content gem. This usually means typing sudo
types transparently. Outside of Active gem install flatfish . If youre
Record and Nokogiri, Flatfish handles the struggling here, any guide on installing
mundane migration detailsnormalizing Rails should help, or you can try using
links and tokenizing and saving media as rbenv+ruby-build or RVM to assist with
binary blobs. the installation and management of Ruby
Now that you know a little about Trekk versions, implementations and gemsets.
and Flatfish, lets get our neckbeards However, be aware that rbenv and RVM
on and walk through an example. For come with their own set of concerns and
Flatfish, download Ruby 1.9.3, and are recommended for those interested
install all of the soft dependencies in Ruby beyond Flatfish. Finally, theres
(also save yourself some time and also an IRC channel: #trekk. For gem
install libxml2-dev, libxslt-dev and version incompatibilities, use the
mysqlclient-dev or your distros Flatfish GitHub Issues.
equivalentsgem dependencies). A Using Flatfish is straightforward. The
note on the soft dependencies, Ruby program parses a CSV. Each row contains
will install without them, but you dont the URL to be scraped, metadata about
want that so be sure to grab them, the URL for Drupal and one or more
in particular libyaml. Rubygems, your columns of CSS selectors. Each CSS
PHP PEAR/PECL equivalent, comes with selector maps to a Drupal field.
Ruby, so now you can install the Flatfish For an example, lets scrape the Drupal
Connect Web site and populate a Bios Now copy the YAML file below
Content Type as well as a handful of blog and change the values to match
posts to demonstrate the media handling. your specifics:
The first step is to create the CSVs. The
bio CSV contains a header row with URL, # DB credentials
Articles and dont have any extra fields. # and AR database tables
GitHub. You can see that the CSS classes csv: '/home/tloudon/lj/example/bio.csv'
with config.yml. During runtime, Flatfish the drush makefile as specified in the
will pull down the content over the Net README.md, and choose a Trekk
and update all of the relative links. (There Server with Flatfish Support.
also is support for a local importation The Flatfish module needs access to
if you have a copy of the site or use the config.yml, the Flatfish generated
wget to mirror it, which can speed up schema.yml and the scraped HTML
the migration substantially.) Flatfish will database. Create a new directory called
create two or more database tables: a flatfish_migrations in sites/all, and
media table and one for each Content place the YAML files in it. Review the
Type. Any files (images, PDFs, docs and so generated schema.yml file, and ensure
on) referenced in the CSS selected HTML that each Content Types machine_name
are saved in the media table. Flatfish matches the Drupal Content Type
considers URLs unique, so only one copy machine name. (Note: Rails pluralizes
of an image or file is saved even if there database tables, so a Flatfish Bio
are multiple references to it. Note that type has a bios table and matches a
the scraped HTML now has tokens to the bios Drupal content type.) Navigate
media table. Take a moment to query the to admin/structure/flatfish. The Flatfish
database and verify that all content saved module parses the YAML files and
correctly. Again, Flatfish supports updates dynamically creates the configuration
and maintains IDs, so you can rerun page items. When you visit the Flatfish
Flatfish several times during a session or module configuration page, the items are
during the course of a project. registered as Migrate classes. This means
On the Drupal side, weve created a database tables are created to store
Flatfish module thats included in Trekk important Migration data, and you now
or available on drupal.org. Trekk has a can see and run the Migrations under
drush makefile to download Flatfishs admin/content/migrate.
required libraries; however, you also can As implied above, all media, regardless
download them manually (queryPath, of content type, is stored in the same
HTMLPurifier and Spyc). Spyc provides database table. Run the media Migration
YAML support; queryPath replaces the first; this will create the physical files and
media tokens, and HTMLPurifier strips add them to the file_managed database
out all nonsemantic markup. The heart table. The files are now accessible
of the module uses Ctools plugins under admin/content/media and are no
and Migrate to provide a reasonably different from any other natively created
automated, dynamic migration. Drupal files.
Download the Trekk tarball, run Next, run all Node/HTML Migrations.
Figure 2. Migrate UI
As mentioned previously, each URL will notice that the HTML is clean.
from the CSV corresponds to a Drupal HTMLPurifier accepts a comma-
node. Because the HTML has simple delimited whitelist of HTML tags with
Flatfish media tokens, its important attributes. Flatfish has defaulted to
that you run the media Migration stripping all divs, spans, classes and
first, so that the files exist in Drupal ids. Although this may change if it
and the system will update them. If proves to be controversial, the Flatfish
you skipped the media first, click the module strips HTML table tags as well.
update check box, and run the Node/ In my experience, legacy HTML tends
HTML Migrations again. You also toward table-driven layout rather than
http://localhost/api/bios/
Listing 1. Trekk Client Source Snippet default where api is
the Services path, bios
/** is the View name, and
* Implements hook_trekk_client_source_schema() default is the View
*/ display. You also can add
function bio_example_trekk_client_source_schema() { query string parameters like
$schema = array(); output=html to show HTML.
Note, other examples and
$schema['bio_example'] = array( details are contained within
'name' => 'bio_example', the Trekk distribution. The
'label' => t('Trekk Bio Example'), Trekk Server is now set up.
'fields' => array( Covering the creation of
'nid' => array( a Trekk Client in detail is
'type' => 'int', beyond the scope of this
'length' => 11, article; instead, I review the
'unsigned' => TRUE, basic process. First, create
'not null' => TRUE, a second instance of Trekk,
), this time selecting the Trekk
'node_title' => array( Client option. Trekk clients
'type' => 'varchar', use Migrate and need custom
'length' => 255 code to parse and import the
), data thats retrieved from the
'body' => array('type' => 'longtext'), server. So, each Trekk Client
'position' => array( has custom code tailored to
'type' => 'varchar', the shared content. This code
'length' => 255 is composed of three primary
), parts: a Source, a Destination
), and a Mapping. (Note: there
'primary key' => array('nid'), are examples within the
); Trekk distribution.)
Youll need to navigate
return $schema; to admin/config/services/
} trekk_client and add a new
Trekk Client configuration
item. You can define the Trekk
Server URL as well as the HTTP method, and each field would have the data
but the Source schema implements type (int, varchar and so on) and length
hook_trekk_client_source_schema(). The where appropriatesee Listing 1 for an
schema is essentially a database-friendly illustration. The only hitch is that the
version of the structure the Trekk Server Trekk Server converts a View into JSON,
endpoint outputs. For example, your bio so it uses the View field labels instead
schema would have nid, node_title, of the machine name as you have in
body and position as the fields, other areashence, position and not
Creating and
Theming a
Custom Content
Type with Drupal 7
Make the most of your content strategy by building and
theming custom content types using Drupal 7. In this article,
I show how to design an Event content type, leveraging some
features with this content management framework.
DANNY ENGLANDER
One of the great new things about types. These might include events, press
Drupal 7 is that its now easier to releases, FAQ, staff, photo gallery and
customize your site content. In Drupal more. What makes these unique? Its all
6, you typically had to use the CCK about the Fields that you add to your
(Content Construction Kit) module for content type.
fine-grained control in customizing A Field is an attribute for the content
content, but that has been folded into type, and these attributes are types of
core for Drupal 7. Drupal 7 is now a true information associated with your content.
content management framework (CMF). If you have an Event content type, you
might need to add date, location and link
Drupal 7: Its All about Fields attributes. Each of those can be realized
When you customize content in Drupal through the use of Fields.
7, it involves creating or modifying
whats often referred to as a content Theming and Nodes
type. Drupal 7 comes with two defaults: A Drupal 7 Node is simply an individual
Page and Article. When building a site, page with content thats rendered using
you often need additional content a specific content type that contains
Figure 2. The content type landing page is where you can edit your content types and
manage their fields and display.
all of your fields. Fields are extremely too much code. There also are other ways
flexible, and there are many possibilities to theme a node, including custom node
for display and theming them, depending templates and the Panels module.
on what you want to do. Theming, in Drupal 7 comes with basic default
regard to Drupal, is the presentational fields, such as Text, Long text, File, Image
layer of the code and content, and there and List. There also are many additional
are various ways to achieve theming Field types that can be added via
from some simple changes in the Drupal contributed (contrib) modules.
Admin UI to more complex custom node
templatesfor example, node--custom. Manage and Edit
tpl.php. In this tutorial, I use the Display To gain insight into existing content
Suite module for theming our node. Its types and Fields on your site, navigate
a visual interface that allows for custom to /admin/structure/types, or use the
layouts without really needing to know admin toolbar: StructureContent types.
Figure 3. You can manage existing fields for an individual content type and add new
ones with a select menu.
Figure 1 shows the administrator Fields and a select menu to add new ones
toolbar at the top of the Admin Drupal for a content type.
UI in the browser. Youll use this a lot
to navigate the admin area for various Tools Needed
tasks. This assumes you have admin Now that you have a basic overview of
access to a Drupal site or at least have how content types work, let me show
been given the proper permissions by you how to build a new one and theme
an admin to see and use the toolbar. it. For this example, lets create and
On the content type landing page, as theme an Event content type. You will
shown in Figure 2, you can see existing need a few additional contrib modules
types, and you would add new ones here. available from drupal.org. Ideally, to
You also can edit a content type, add follow along with the tutorial, youd
and edit Fields, and manage its display want a fresh install of a Drupal 7 site,
from this page. Figure 3 shows existing and download and set the default theme
to the Professional Theme. called drush where you can install core
If you are not familiar with how to and download contrib modules, but for
install Drupal, its actually not that the sake of this tutorial, Im using the
hard, and you can install it in a LAMP Drupal Admin UI. If you really decide to
environment. If you already have a dive in head first to Drupal, drush can be
local development machine with LAMP, a huge time saver.
its a matter of creating a new MySQL
database and following a point-and-click Mock It Up
GUI install for Drupal. There are links at When creating a new content type, I
the end of this article in the Resources like to do a quick mock-up to get a
section for some basic Drupal install better picture of how I want the finished
information. Note that Drupal has an product to look. Figure 4 shows what I
entire command-line utility of its own came up with for my Event.
should be sufficient, but there may be API, Date popup and Display Suite, and
times when you run into a bug and need then click Save configuration.
to use the latest dev release. Figure 5 Using the admin toolbar, click on
shows an example of release information Appearance, and activate the Professional
for a contrib module on drupal.org. Theme listed under Disabled Themes. Use
Download the modules, untar them, the Enable and set default setting that
and put the resulting folders in the will enable it and bring it up to the top
/sites/all/modules folder from Drupal root. under Enabled Themes.
Although you will see a Modules folder
at root, never add third-party modules Get a Google API v3 Key
to this one; its a core folder that gets Youll need to add a Google Maps
updated or changed only when a core JavaScript API v3 Key to display a
Drupal release comes out. Likewise, map for an event location. Go to the
download the Professional Theme, untar Google API console and log in with
it, and put it in /sites/all/themes. your Google account (or create a
You also need to download some map Google account if you havent already).
markers from the Get Locations project See Resources for links. Once logged
page. The getlocations-markers.tar.gz in, generate a new key, or use an
file should be sufficient. Untar this existing one from the API Access tab.
file, and put it in sites/all/libraries/ Back in Drupal, use the admin toolbar
getlocations/markers. Most likely you to go to Configuration, and then under
will have to create the Libraries folder Web Services, click on Get Locations.
on a new Drupal install, but if it exists Expand Google API Key, enter your key,
already, simply make a new folder and save the configuration.
within that called getlocations, and
then put the newly untarred Markers Set Your Locale and Create a
folder within that. Custom Date and Time Format
Now is a good time to set your sites
Activate Contrib Modules Locale as well. From the toolbar,
and Theme go to ConfigurationRegional and
Go to the Drupal Modules Admin page LanguageRegional settings or admin/
located at /admin/modules, or from the config/regional/settings. Chances are
admin toolbar, click on Modules. Check your default time zone already is set,
the check boxes for Get Locations, but its good to confirm or adjust
Getlocations Fields, geoPHP, Geocoder, it. Accept all other defaults here
Libraries, Chaos tools, Link, Date, Date and save. Also, from Regional and
Figure 7. The finished Fields page for Event. You can re-order the fields by dragging the
little + icons under the label, but you must save the page after doing so.
far right; you can click on those to At the bottom of Manage Display,
fine-tune your settings, but always find the tab called Layout for event in
remember to choose Update, and default. Click, and using the Select a
then save the page after any changes. layout list, choose Two Column, and
Youll notice with the Date and save the page. Youll notice you have
Event photo, you now have the an updated UI showing Right, Left and
respective format and style you Disabled. All Fields default to Disabled,
created previously. so position the Fields where you want
Lets add in a Display Suite layout; them in your new two-column node
this is where all the magic happens. layout. You either can drag your Fields
up to the right or left area or use the From the admin toolbar, click
Region select list to choose. I find the on Content, and then choose Add
latter to be easier. Figure 9 shows the content, and choose Event. You now
layout after repositioning Fields and will see a blank node create form.
saving the page. Fill in a T itle, choose your Date, and
fill in some Overview Text. Next,
Add CSS to the Theme choose an address for your event, and
By default, the two-column Display once its filled in, click the Geocode
Suite layout is split 50%, but lets add this address button, and your little
some CSS to our theme to mirror the map below will re-center itself on
wireframe. Open styles.css, located at your address. Finally, upload an
sites/all/themes/professional_theme/, image, choose a link/title, and save
and add this code after the final your node. Figure 10 shows the final
closing brace at the end of the file. themed layout.
Youll notice this CSS file has media
queries in it, and for the sake of this
demo, lets add our styles in after any
media query, but you also could theme
this per media query:
.group-right {
width: 36%;
padding-left: 2%;
float: right;
}
.group-left {
width: 62%;
}
.field-name-field-event-image {
margin-top: 20px;
}
.getlocations_map_canvas {
max-width: 100%;
}
Figure 10. The Final Themed Layout for the Event Content Type
Theres so much more you can editor to the Overview Text area. If
do with custom content types and you want to get more hands-on with
theming in Drupal 7; this is just the code, you could dispense with Display
tip of the iceberg. To enhance the Suite and add a node--event.tpl.php
content editor experience, a nice file to your theme folder and theme
addition would be to add a WYSIWYG the Fields individually.
Resources
Professional Theme (front-end theme pictured in the demo): http://drupal.org/project/professional_theme
Date: http://drupal.org/project/date
Link: http://drupal.org/project/link
Geocoder: http://drupal.org/project/geocoder
geoPHP: http://drupal.org/project/geophp
Tips for
Writing
Interoperable
Drupal
Distributions
Want a crash course on how to write distributions for the
Drupal platform? Get tips and expert advice from a longtime
Drupal contributor and distribution developer. This article is
packed with examples of problems and solutions for writing
plugins that integrate cleanly with other distributions and
make the best use of the Drupal toolkit.
NEDJO ROGERS
First off, what is a distribution and why potter. But, if its your first time spinning
would you write one? Even more than clay, your plates likely to come out
many other content management system wonky or crack when it hits the kiln.
(CMS) frameworks, Drupal is up for What you want is a moldsomething
pretty much any task you set it. You can thatll give your plate just the right
think of Drupal like a potters workshop. thickness and structure and shape. From
Want a vase or plate or mug or there, sure, you can add your own details
Halloween mask? You can find different and dab on whatever glaze you like.
kinds of clay on the shelf and the potters So if Drupal is like a potters workshop,
wheel is right over therego for it! a distribution is the plaster mold
No problemas long as youre a skilled something you can use quickly to make
an expertly designed product that fits a the existing projects. Thats what open
particular purpose. source is all about.
Theres a growing set of Drupal W ith the why nots out of the way,
distributions available. Need to build a here are some key reasons to consider
Web site for a conference, newspaper, writing a distribution:
government agency, on-line store or
nonprofit organization? Rather than n Youre working with or for a large
starting from scratch, youll get a huge institution or network that will
leg up if you start with the Conference need many sites built along a
Organizing Distribution (COD), common model.
OpenPublic, OpenPublish, Commerce
Kickstart or Open Outreach. n Youve got a sizable contract to
build a Web site that fits a need
Why Write a Distribution? not already covered by an existing
Maybe the first question should distribution; you expect to be doing
be, what are some top reasons similar sites in the future, and
not to write a distribution? Fame youve got room in the project
and fortune, for onewriting and to generalize.
maintaining a distro is hard work. It
eventually may create some income n Youre tired of doing the same
in the form of contracts to extend site-building work over and over
existing functionality, but in the short and want to focus on refinements.
term, youve got a ton of designing
and coding to get through. As for n You have a burning interest in and
fame, well, despite their merits, most commitment to a particular sector
distributions are notably modest in or need and want to dig in over the
terms of both community profile and long term.
the number of actual installs.
Another good reason not to write n Youre committed to lowering the
a distribution is there already may be financial and technical barriers to
one (or more) in existence that fits the technology access.
bill. True, those existing distributions
may not do everything you want them n Youre up for sharing your work,
to do exactly the way you would have even though doing so will feel
done it. But, rather than doing it your like pinning a badge to your chest
own way, try pitching in and improving labeled complaints department.
n A theme is the set of templates that gives a site its particular look and feel.
n More distros and sites will be able to use your work. Its frustrating to build
something and then watch someone else reproduce pretty much exactly what
you already did only with a few details changed. If you make it easy to do so,
others will be more likely to use, and maybe even contribute back to, what
youve begun.
that extends and updates Kit, providing her comments in a recent thread on
guidelines for a higher level of integration. drupal.org. Her concerns, to paraphrase,
The Debut project page on drupal.org were that the apps model clouds
also links to developer documentation waters already muddied by features and
on building new Debut features. modules and whatnot and also detracts
Other distributions like OpenPublish from getting usability fixes into Drupal
include detailed documentation on core and drupal.org where they can
their Web sites about how to write help everybody.
features or apps that extend the That said, well, Apps is being
distribution. Read up! adopted as a tool in many Drupal 7
Consider Building Off a Base distributions and can help solve both
Distribution Panopoly is the first development and usability issues.
distribution written specifically to For developers, Apps makes it easier
be a base for other more-specific to incorporate features from other
distributions. Panopoly tackles some distros into their own. For example,
key administrative, usability and design Apps is what facilitates using Panopoly
challenges that any distros will face. as the basis of your own distribution.
Building a distribution off Panopoly For site builders, Apps gives a one-
will save you having to solve all those click solution for installing a feature
problems yourself. It also will facilitate complete with all of its dependencies
interoperabilityat least with other on a site that wasnt based on a
Panopoly-based distros. The Panopoly distribution.
project page on drupal.org includes Dont Re-invent the Feature
documentation on how to base a Even beyond building off a base
distribution off of Panopoly. distribution, you may be able just to
Spark is a newer initiative thats take and use a lot of what you need
also tackling usability and design from existing features. Before writing
challenges. Its not yet fully primed to yet another event or blog or mapping
be a base for building other distros, or social-media feature, take a good
but discussions are underway, and its look at whats already out there.
a project to keep an eye on. Seriously ask yourself: what would
Consider Packaging Your Work I need to do to use the existing
as Apps Not everyone is thrilled with feature directly in my distribution?
the Apps model. Apps makes respected Incorporating other peoples work can
Drupal developer and evangelist Angie free you up to focus on what youre
Byron (webchick) wincejudging by really interested in. Think of it this way:
the alternative is having to build and features, consider having each of your
maintain everything yourself. Ouch! feature modules create the general-
And, what better path to use roles it needs at install time using
compatibility could there be than regular Drupal APIs. Heres an example
actually using the same code? of how you might do this in a modules
Avoid Dependencies of One install file using hook_install(), which
Feature on Another No, really, Drupal core calls when a module is
avoid themeven soft dependencies. first installed:
Unless your new feature is strictly
enhancing an existing featurelike, /**
having dependencies on other features * Create "administrator" and "editor" user roles
module wont let you enable two // If there isn't an existing role by this
the links? );
other feature authors from using the // types and an 'example_social_types' key.
same approach. Instead, you can build // Add any hits to the $social_types array.
social linking easily. Heres an example. // Merge into the existing variable's value so
Say youre building a feature that // as not to overwrite existing settings, using
uses the Service links module, which // variable_get(), array_merge(), and then
service_links_node_types. In your }
* */
* social linking. }
*/
Yes, there are exceptions to all of * Add custom taxonomy terms to the event_type
Resources
Tools for Working with Distributions:
Apps Module: http://drupal.org/project/apps
OpenPublic: http://drupal.org/project/openpublic
OpenPublish: http://drupal.org/project/openpublish
Panopoly: http://drupal.org/project/panopoly
Spark: http://drupal.org/project/spark
convince Drupal to recognize code- Draw on the best of whats out there.
based configuration in Drupal 7 may And, in turn, make your feature, app
soon be a thing of the past. or distribution as interoperable as it
Big changes of course bring their can be. Doing so will help others make
share of challenges. Theres a lot that the most of your contribution and also
still needs to settle out before itll help future-proof your work, whatever
be clear just how features, apps and Drupal 8 brings.
distributions will translate to Drupal
8. But with core Drupal devs solidly Nedjo Rogers has been an active Drupal contributor
addressing configuration management since he posted his first module in 2003. He is the
in Drupal core, the future of Drupal technical lead of the Open Outreach Drupal distribution
distributions looks bright. for nonprofit organizations and a partner at Chocolate
In the meantime, if youre venturing Lily Web Projects, http://chocolatelilyweb.ca. When not
into the world of apps or features or coding, he writes poetry and folk songs and tries to
distros, take the time to do it right. learn the accordion.
Read
LINUX JOURNAL
on your
Android device
Download the app
now in the
Android
Marketplace.
www.linuxjournal.com/android
For more information about advertising opportunities within Linux Journal iPhone, iPad and
Android apps, contact Rebecca Cassity at +1-713-344-1956 x2 or ads@linuxjournal.com.
Cache in Drupal 7
Drupal is a powerful and very flexible, but often heavy,
platform. In this article, I show how to utilize all of its
advantages and still make it perform fast.
JANEZ UREVC
architecture for Web applications that time the same query is executed.
uses disk to store data permanently Substantial savings can be achieved
and RAM as an efficient cache medium this way, because repeating queries
for the most-used pieces of it. happens a lot in Web apps.
There are many cases when you
usually will want to use cache in Web Cache in Drupal 7
development, including the following: Cache is implemented as a very flexible
and pluggable framework in Drupal 7.
n Heavy database queries. Here are three of the most important
concepts to understand:
n Output that is expensive to render.
n A cache item is a complete piece
n Complex numerical calculations. of data that is stored in cache. A
developer addresses each cache
n Code with substantial use of I/O item with a key that obviously
(disk). should be unique.
least one Drupal module. Back ends improvement, as PHP files generally
that are most commonly used in the do not change much. It is relatively
Drupal ecosystem also are very popular simple to install and very easy to
in general Web development. Each configure. It should be used on every
of them has its own advantages and Web server that runs PHP (production
disadvantages, and each will satisfy and development).
different needs. Another feature of APC that people
Some modules implement more are not always aware of is the user
than just cache support. They often cache. The user cache uses APCs shared
implement sessions and semaphore memory to store users (developers)
(locking) handlers too. That also will custom data, and it definitely can be
speed up your site, as a typical Drupal used for cache purposes. It is very fast,
Web site uses those mechanisms because it stores data directly in PHPs
frequently. Refer to each modules memory. Assuming that you already
project page and README.txt file in have APC installed on your server
order to utilize their advantages. (and you should), it also does not add
further complexity to the server stack.
Database Cache (Default) Data in APC is not stored permanently;
Drupals default cache implementation is you will lose all your data if the power
obviously very easy to use, as you get it goes down. Another disadvantage
for free when you install Drupal. It also is the fact that each server maintains
doesnt add any additional complexity its own version of cache. This will
to your server stack, because it uses a cause cache warm-up to take longer
database (usually MySQL). This back end in high-availability (more Web
should work totally fine for most smaller servers) setups. This also can lead to
sites. The problem is its speed, because synchronization problems.
it writes all data directly to disk. Writes
are especially very slow, as MySQLs query Memcached
cache helps to boost read performance. Memcached is an open-source, high-
Another disadvantage is the fact that it performance, distributed memory object
uses a database that already is under very caching system (http://memcached.org).
heavy load on high-traffic Web sites. It is very popular and is used on many
well-known sites. It runs as a separate
APC User Cache dmon, which means that it adds another
I already mentioned APC (http://drupal.org/ level of complexity to the server stack. It is
project/apc). It provides a lot of performance very easy to configure and administer, so
Figure 1. This performance overview of all the back ends described in this article
shows that APC is the fastest and MySQL (DB) the slowest. Redis and Memcached are
relatively similar when it comes to performance, but that could change if Redis would
write its data to disk often. MongoDB is very fast, especially when it comes to writes.
is much faster than MySQL, and it The paths in the above example should
stores data permanently. You will need be adjusted to your specific installation.
to install a PHP extension in order to When you include cache back ends, you
use it. It is probably the most complex need to set the default:
to configure and administer of all the
back ends I describe here. MongoDBs $conf['cache_default_class'] = 'MemCacheDrupal';
include_once('./sites/all/modules/memcache/memcache.inc');
$conf['cache_cache_menu'] = 'DrupalMongoDBCache';
# Redis
$conf['cache_backends'][] = // etc....
'sites/all/modules/redis/redis.autoload.inc';
Page and Block Cache save HTML output of Drupal blocks (parts
Page and block cache are implemented of a page). Blocks also can be cached
in Drupal core, and youll get them with for registered users, which will give you
every Drupal installation. Page cache will some performance improvement for
save the HTML output of the entire page non-anonymous traffic. Blocks are stored
for anonymous users and store it to the in the cache_block bin.
cache_page bin. This HTML will be Both are very easy to enable and
displayed to all anonymous users, which configure by navigating to admin/config/
will bypass most of the Drupal bootstrap devel/performance.
and the entire page-generation process.
This will save a huge amount of time and Views Cache
server resources. Views is the most frequently used Drupal
Block cache, on the other hand, will module (http://drupal.org/project/
views). It provides a flexible method for
Drupal site designers to control how lists
and tables of content, users, taxonomy
terms and other data are presented. There
probably arent many serious Drupal Web
sites that dont use this module.
Views implement a cache mechanism
that will save the result of a views query
and its HTML output. Views will operate
with its cache on a timely basis, but
you can implement your own plugin to
achieve totally customized behavior. The
Panels Cache
Panels is another powerful Drupal module
(http://drupal.org/project/panels).
It allows you to build complex page
layouts and configure and control them
in a really intuitive way. Besides its many
other features, it also has a powerful
cache implementation. Panels, by default, Figure 4. Configuration for the Panels Cache
Figure 5.
Configuration of
Devels Query
Cache
will allow you to cache almost everything but it wont help you much if you dont
and configure granulation and lifetime. optimize your queries and code first.
Again, this can be completely customized Cache will just save you from running
with your own custom plugins, resulting them over and over again, but you still
in even more flexibility. will have to execute your slow queries
The panels cache is configured on the and run your slow code from time to
configuration page for each panel. It is time. However, Drupal provides a lot of
usually configured on a per-pane (part of tools to optimize those things too.
a page) basis. The Devel module (http://drupal.org/
project/devel) implements a handy query
How to Optimize Your Drupal log, which will print the list of all queries
Page for Performance that were executed during a given request
Cache is a very powerful tool in Drupal, in the footer of your page. This allows
Figure 7.
XHProf
Profiler
USENIX.org:
a Case Study
of a Migration
to Drupal
The new USENIX.org is built on Drupal with an extensive
Salesforce.com integration, Apache Solr-based faceted searching,
e-commerce from the Drupal Commerce suite and microsites
built with Organic Groups. Dozens of custom Drupal modules
make this powerful system simple for staff and visitors.
JODY HAMILTON
physical magazines, books and offprints. To a pleasure to use because it uses the same
cater to these diverse e-commerce needs, entity-based architecture as core Drupal 7.
our team used the Drupal Commerce
framework along with Commerce Coupon, Houston
Commerce Custom Line Items, Commerce USENIX required a complex bi-directional
Devel, Commerce Features, Commerce File, integration between Salesforce.com
Commerce Flat Rate, Commerce Payflo and the new Web site. We used our
Pro and Commerce Shipping to enable the own Houston Command Center
sale, pricing and access to products. (http://houstoncommand.com) over the
Certain files on the Web site are free to more widely used Salesforce Drupal module
select users (depending on membership to allow flexibility with the data model as
status or conference registration) but well as to provide queue management and
unavailable or available for purchase by failover support. Houston is OSS weve
others. Files also can be set to become evolved during several large integration
public at a specified date, so that they projects. It addresses challenges in
are no longer conceptually a product for integrating with SaaS products, including
sale on the site. Multiple product formats handling API limits and downtime. It
for one piece of content are routinely provides a framework for mapping the
sold (such as print and electronic book data model between systems and handles
formats). These needs did not map well queuing and backups.
administratively to the Drupal Commerce Using Houston, we linked authentication,
model of separating the product and its user profiles, membership status, conference
display (the content, aka Drupal node) registration, grant applications, pricebook
and would have made for a complex and entries and e-commerce purchases
tedious workflow for content creation. between the two platforms in a seamless
Fortunately, the Commerce API facilitated manner. Existing USENIX.org members
a solution. Our team was able to hide are able to log in to the new site with the
the creation of products from Web site same credentials they used pre-Drupal
administrators by auto-creating and (which were mainly used in .htaccess-style
updating associated product files, SKUs, authentications) by comparing their
attributes and prices when content is hashed passwords to those migrated into
created and updated. We also used the the CRM. Once authenticated, users can
Commerce API to implement sophisticated manage their membership and profile
membership levels and benefits, including information on the new Drupal site, and
free products per year of membership and USENIX staff can view and edit that data
discount scenarios. The Commerce API was on Salesforce.com or on USENIX.org. When
users register for a conference on the site, site to grant access to attendee-restricted
their profile information is used to pre- pages and files. Staff even can manage the
populate a registration form on CVent (an prices of different categories of products
SaaS event management system). After sold on the Drupal site (for example,
payment, the CVent registration data is the current price of an audiobook for a
sent to the Salesforce.com CRM, where it USENIX member) from the Salesforce.com
is then available to Houston and the Drupal CRM. By centralizing user history, such as
Figure 3. A conference microsite has a custom theme, banner, navigation and content,
such as sessions and sponsors.
automatically. It also keeps content schedule pages, for example, vary in format
creators in the familiar content creation between conferences. The staff wanted full
interface rather than requiring them to control over the markup of these individual
learn another Drupal system. listings while still benefiting from dynamic
Some of the conference pages required content management of each session
even more customization, pushing past displayed on the schedule. For these cases,
the limits of what can be automated and we implemented a token-based HTML
programatically displayed. The conference system. With this system, an editor creates
in site-wide searches. Viewing these Drupal node reference fields. These imports had
nodes of legacy content results in a redirect to be repeated as new content was added
to the page on the real legacy site, now to the legacy site, so they were written as
hosted at http://static.usenix.org. Drupal modules containing custom Drush
commands. These commands took a URL
Scraped Content and scraped its HTML, parsed it into arrays
We used the Simple HTML DOM parser to of data, built Drupal objects representing
traverse sections of the old USENIX Web site content, files, products or categories and
and programmatically create new Drupal saved these programatically. This approach
nodes with dates, files, images, text and was used to import some conference
content, magazine content and Short Topics structure: nodes of type session, paper,
in System Administration books content. discussion and speaker.
happening. But, what about people just you use Drupal are the people who built
starting with Drupal? Drupal. How can you meet these people?
Say youre a system/network/database By contributing to core.
admin whos had Drupal thrust upon
you by someone higher up. That never How Can I Contribute to Core?
happens, right? I had a sysadmin friend The first thing you have to do to before
recently tell me that someone in her you can make a contribution to Drupal
organization was excited about using core is register for an account at drupal.org.
Drupal. Whats that going to mean for This allows you to do all sorts of small
my friend? You probably dont care, things immediately, such as update
but you do care about what it would documentation. You can contribute in
mean for you, dont you? Contributing several different ways. For the Linux
to core can help you get a much better Journal audience, Ill first focus on the
understanding of how a Drupal system standard approach, which is more
may impact the system/network/database developer-centric and involves using the
resources you administer. This is especially Drupal Issue Queue. After that, Ill go
true once you figure out what your into some ways even a non-coder or
organization wants to do with Drupal. non-technical person can contribute.
I look at specifics regarding that in the
How section of this article. Code Monkey Climb Ladder,
What if youre the Web person Help Drupal!
for your organization whos had Drupal The approach most developers (but not
thrust upon you, but with a mandate just developers) will be comfortable
to make it usable, pretty and accesible with can be seen on the Drupal
or to look like our company, not every Ladder (http://drupalladder.org/
other Drupal site? First, realize how ladder/ee503327-50be-1904-8d04-
lucky you are to have higher-ups who are 9499098cad64). The Drupal Ladder is
enlightened enough to choose Drupal. the result of an effort to get more people
They could have thought Flash was the involved in contributing to Drupal core. It
next big thing. Second, realize that is made up of lessons and materials to
contributing to core can help you learn help people learn about and contribute
the best ways to do that. Again, more to Drupal (http://drupalladder.org/
details on that in the How section. node/1). Its also worth noting that
If youre someone new to Drupal, Drupalize.me, an on-line repository
youll probably want all the help you can for Drupal training videos created by
get. The people best positioned to help Lullabot, has a free Learn the Drupal
instructions specific to working with Drupal 2. Someone working on the issue queue
core (http://drupal.org/project/drupal/ tests an issue to see if they can reproduce
git-instructions) available for those new it. If they cant reproduce it, theyll post a
to Git or Drupal. Dont forget, theres comment for that issue, probably asking
also a lesson at the Drupal Ladder site for more information. This will alert the
(http://drupalladder.org/lesson/ original poster and anyone else who may
027b5839-7a74-af04-6905-fee2d01c7ef4) be following that issue. If they can,
and a video at Drupalize.me. With the theyll add a comment noting this and
first two setup steps out of the way, perhaps move on to the next step.
youre ready to dive into the Issue Queue 3. Someone sees an issue they know
and start meeting Drupal Folks. how to fix. They may explain what
needs to be done (this is often done by
Steps 35: Using the Issue more experienced developers when they
Queue and Interacting with the encounter easier problems) or create
Drupal Community the patch they think will fix the issue.
Now, Im going to depart a bit from When a patch is created, its submitted
following the Drupal Ladder, by outlining by attaching it to a new comment in the
the basic steps for dealing with a bug in issue queue. Drupals automated testing
Drupal core, which probably are similar system (SimpleTest) will do basic testing
across open-source projects. Whats on the patch.
important to note is that youre helping by 4. Someone sees a patch that has passed
taking part in any of these steps. Please automated testing and will test it manually
note, this is my broad strokes overview on their own local Drupal install. Theyll
of the process. Its not an official include before-and-after screenshots of the
outline or process document. Im sure behavior that created the bug and how its
Im leaving out some details, but this will been fixed (or not fixed).
more than suffice for an introduction: 5. Someone with commit access (a small
1. Someone has a problem and adds group of people, https://drupal.org/
an issue to the Drupal Core Issue Queue node/3060/committers) will commit the
(https://drupal.org/project/issues/ successful patch to Drupal core after its
drupal?categories=All). When doing been successfully Reviewed and Tested By
this, be as detailed as possible about the the Community (RTBC)
conditions that cause the bug to appear.
People will need to be able to reproduce Focus on Your Strengths
it. Screenshots help. You need to have an My use of the word someone in the
account on drupal.org to post an issue. steps above was important because you
would help build new Drupal architects more concerned with the cache
by letting members of the community (https://drupal.org/project/issues/
learn more about the inner workings of drupal?categories=bug&component=
Drupal. The benefit for new contributors cache+system) or database
is that theres now an official, well-formed (https://drupal.org/project/issues/
(and constantly evolving) on-ramp for drupal?categories=bug&component=
new contributors. database+system) systems and how
Currently, Core Mentoring Hours they work. Looking at bugs related
happen twice each week, Tuesday, to those systems can help expand her
02:0004:00 UTC, and Wednesday, understanding of how they function.
16:0018:00 UTC. Here in Texas, thats If her organization is using MySQL
911pm Mondays and 11am1pm (https://drupal.org/project/issues/
Wednesdays. The Core Mentoring page drupal?categories=bug&component=
has time-zone converters so you can mysql+database) or PostgreSQL
find your local times. If you can make (https://drupal.org/project/issues/
yourself available during one of those drupal?categories=bug&component=
time slots, go into the #drupal IRC postgresql+database), she may want to
channel on freenode.net and announce focus more on those. The Web person
that youre there for Core Mentoring may want to focus more on things like
Hours (http://drupal.org/irc). You the markup, CSS or JavaScript subsystems
promptly will be put to work and/or I mentioned earlier. Or, if the site has a lot
assisted with questions you have about of community activity, maybe looking at
how to contribute. I participated in the the Comment module (https://drupal.org/
first COH/CMH last August, and Ive project/issues/drupal?categories=bug
learned quite a bit. &component=comment.module) would
be helpful.
Step 6: Pick Your Spots, Call If you know what parts of Drupal
Your Shots youre more interested in, point that
Remember those examples I mentioned out while youre in Core Mentoring
about the people who had Drupal Hours, and you can work on those areas.
thrust upon them? Remember when Or, work on it on your own. Another
I said youd be able to find ways to option is to look at the various Drupal
contribute that would benefit your 8 Core Initiatives (http://drupal.org/
specific functions? This is where the community-initiatives/drupal-core),
various Drupal core subsystems come which focus almost exclusively on
into play. My sysadmin friend may be specific areas, such as configuration
management, Web services or mobile. above. If youre curious about any of them,
Discussion of those topics deserves you can take a look at the docs Ive linked
its own article, but take a look at the to or ask in Core Mentoring Hours.
Initiatives page and see what looks good.
Conclusion
Im No Code Monkey Genius, Drupal is an excellent CMF that offers a
So I Cant Contribute lot of functionality out of the box, as well
There are a number of ways non-coders as for people wanting to build something
can contribute. Every issue in the core custom. In a more general sense, Drupal
queue should have a clear, concise is also an open-source project with a very
summary. They dont. The Issue Summary welcoming and supportive community. In
Initiative (http://groups.drupal.org/ the words of Angela webchick Byron,
node/167534) looks to fix this. If you open-source evangelist, a Drupal core
can read and write English, you can help co-maintiner and April 2011 Linux Journal
here. Change notices (http://drupal.org/ cover girl (http://www.linuxjournal.com/
node/1314040), although slightly more content/interview-angie-byron-drupal),
technical, involve documenting changes Drupal is a Do-ocracy. Its not about
that already have been made. So, if who you are; its about what you do.
theres a patch that changes an API or My own experiences have confirmed
adds/removes a function, a Change this. Theres very little cliquishness, and
Notice is needed. Heres an example of anyone whos willing to learn about
one I worked on for a new function that the community standards is welcome
themes (styles) date/time information to contribute. This article exists only
(http://drupal.org/node/1441334). I because Ive come across so many smart
didnt write the patch, just the Change and helpful people contributing to the
Notice. Finally, as a member of drupal.org, Drupal community. Join us!
you can update most of the documentation
on the site, and there is a lot! As an Kojo Idrissa is not an MBA. He has an MBA. Theres an important
example, while I was writing the paragraph difference. A holistic mixture of tech guy, business guy,
on Core Mentoring Hours, I updated China guy and educator, he fits into more than one space.
the time-zone conversion link for 02:00 When hes not being that guy, hes learning new ways to
UTC Tuesday. It was going to 02:00 UTC build things and solve problems with technology, improving
Monday, probably because the Mentoring his Chinese or honing his teaching skills. Hes co-SIG Leader
Hours started on Monday/Wednesday. It (and resident Drupal Guy) of the HAL-PC Web Design
was a simple fix, but each bit helps. SIG and a member of the Houston Drupal User Group. Hes
Ive done all three of the things mentioned Transition in the Drupal IRC channels and on drupal.org.