Drupal 7 Cookbook Over 70 recipes that will advance your Drupal skills from novice to pro Dylan James BIRMINGHAM - MUMBAI Drupal 7 Cookbook Copyright © 2012 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: July 2012 Production Reference: 1050712 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.. ISBN 978-1-84951-796-6 www.packtpub.com Cover Image by Asher Wishkerman ([email protected]) Credits Author Project Coordinator Dylan James Michelle Quadros Proofreader Reviewers Aaron Nash Jacques R. Blier Anand Narayanaswamy Indexer Veturi JV Subramanyeswari Hemangini Bairi Acquisition Editor Graphics Sarah Cullington Manu Joseph Lead Technical Editor Production Coordinator Shreerang Deshpande Nilesh R. Mohite Technical Editor Cover Work Madhuri Das Nilesh R. Mohite About the Author Dylan James is an open source developer from and based in South Wales. After gaining a Computer Science degree from Cardiff University, Dylan got experience as a database developer for Walkers snack foods before going on to work at the Welsh media company, Tinopolis Interactive, where he worked as a Lead Flash developer on some large projects for clients such as the BBC, LearnDirect, the MoD, and The Cambridge University Press. It was at Tinopolis that Dylan got his first taste of developing using open source platforms, delivering sites for clients using Joomla and Moodle. After leaving Tinopolis in 2010, Dylan began working at a web agency in Swansea, creating Drupal websites for some high profile clients. For updates and errata, please visit www.dylanspencerjames.com If I would like to thank my parents, Janice and Julian, my sister Lauren, her husband Kristian, and all of my friends, for all of their encouragement and support, and the occasional sanity check! About the Reviewers Jacques R. Blier, with his background in typography and communications, got quickly interested in Internet technologies. Since 1994, he has participated in the creation and implementation of Internet websites, and also provided training on new technologies. In 2004 he created his own computer services and communications business, xMac info. With extensive experience in sales, technical support, training, networking, and user interface design for software used by cellular operators, Jacques became interested in Drupal, since 2005. Since then, he has been using this development platform for creating and developing all types of websites. He specializes in CSS and prefers to create the Drupal themes that people ask him, from scratch. Anand Narayanaswamy is an ASPInsider who works as a freelance technical writer based in Trivandrum, India. He had worked as a technical editor/reviewer for various publishers such as Sams, Addison-Wesley, Mc Graw Hill, Packt, and ASPAlliance.com. Anand has expertise in the installation, management, and usage of popular ASP.NET and PHP based blogs/Content Management Systems (CMS). He is the author of Community Server Quickly (www.packtpub.com/community-server/book) published by Packt Publishing and runs www.learnxpress.com. First, I would like to thank the almighty for giving me the strength and energy to work every day. I specially thank my father, mother, and brother for providing valuable help, support, and encouragement. I also thank Michelle Quadros, Project Coordinator, Packt Publishing for her assistance, cooperation, and understanding throughout the review process of this book. Sree (also known as Veturi JV Subramanyeswari) is currently working as Drupal Architect at a well known software consulting MNC in India. Post joining this company she served a few Indian MNCs, many start ups, and R&D sectors in various roles such as programmer, tech lead, and research assistant. She has around 8 years of work experience in web technologies covering media and entertainment, publishing, healthcare, enterprise architecture, manufacturing, public sector, defense communication, gaming, and so on. She is also a well known speaker who delivers talks on Drupal, Open Source, PHP, Women in Technology, and so on. She reviewed other tech books such as the following : f Drupal 7 Multi Sites Configuration f Building Powerful and Robust Websites with Drupal 6 f Drupal 6 Module development f PHP Team Development f Drupal-6-site-blueprints f Drupal 6 Attachment Views f Drupal E-Commerce with Ubercart 2.x f Drupal 7: First Look I would like to thank my family and friends, who supported me in completing my reviews on time to a high quality. www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? f Fully searchable across every book published by Packt f Copy and paste, print and bookmark content f On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Chapter 1: Installing and Configuring Drupal 7 Introduction 7 Installing Drupal 8 Installing Drupal distributions 13 Installing modules and themes 14 Setting up site search 16 Creating a multi-site Drupal installation 18 Chapter 2: Creating and Publishing Content 21 Introduction 21 Creating a basic page and adding it to the main menu 22 Installing and configuring a WYSIWYG editor 26 Editing existing content and adding an image 29 Adjusting the tabbed settings for content nodes 33 Configuring comments 36 Publishing an RSS feed of basic pages 39 Chapter 3: Working with Blocks 41 Introduction 41 Adding a new block 42 Creating a submenu block 45 Creating a Superfish menu block 49 Creating a block with Views 52 Adding a new block region to a theme 55 Creating a mega-footer menu 59 Conditional display of a block 64