1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Pro drupal 7 development pdf

721 4K 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 721
Dung lượng 12,05 MB

Nội dung

this print for content only—size & color not accurate spine = 1.03125" 720 page count PPI = 692 CYAN MAGENTA YELLOW BLACK PANTONE 123 C Todd Tomlinson Pro Drupal 7 Development, THIRD EDITION Many of the most widely recognized websites on the planet use Drupal as the platform for delivering content and functionality to their visitors. With the release of Drupal 7, a new era of content management emerges in the market with features and functionality that raise the bar on what you can accomplish on the web. With Pro Drupal 7, you’ll discover how to dig deep into Drupal’s features to create amazing solutions. I wrote this book with a focus on the developer who is responsible for cre- ating and extending the capabilities of a website on Drupal. We’ll cover every- thing from the fundamentals of the Drupal platform, understanding and using Drupal’s APIs, writing your own modules to extend Drupal’s functionality, writing secure code, building high performance Drupal websites, and other topics that will help you along the path of becoming a Drupal expert. What you can do with Drupal is only limited by your imagination and the time that you have to put into learning the richness of what Drupal provides to you, the developer. Pro Drupal 7 gives you the tools you need to take full advantage of what Drupal offers. US $49.99 Shelve in Web Development/PHP User level: Intermediate–Advanced THE APRESS ROADMAP Beginning Drupal 7 Foundation Drupal 7 Pro Drupal 7 Development Pro Drupal 7 for Windows Developers www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN 978-1-4302-2838-7 9 781430 228387 54999 Todd Tomlinson, Author of Beginning Drupal 7 BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® THE EXPERT’S VOICE ® IN OPEN SOURCE Pro Drupal 7 Development THIRD EDITION Learn how to use the content management framework to create powerful customized web sites Tomlinson THIRD EDITION Drupal 7 Development Companion eBook Available Pro Download from Wow! eBook <www.wowebook.com> Pro Drupal 7 Development Third Edition ■ ■ ■ Todd Tomlinson John K. VanDyk Pro Drupal 7 Development: Third Edition Copyright © 2010 by Todd Tomlinson and John K. VanDyk All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2838-7 ISBN-13 (electronic): 978-1-4302-2839-4 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Michelle Lowman Technical Reviewers: Joshua Brauer, Robert Douglass, Peter M. Wolanin Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Anita Castro Copy Editor: Mary Ann Fugate Production Support: Patrick Cunningham Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. For information on translations, please e-mail rights@apress.com, or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. iii Contents at a Glance Foreword xxv About the Authors xxvi About the Technical Reviewers xxvii Acknowledgments xxviii Introduction xxix ■Chapter 1: How Drupal Works 1 ■Chapter 2: Writing a Module 13 ■Chapter 3: Hooks, Actions, and Triggers 33 ■Chapter 4: The Menu System 57 ■Chapter 5: Working with Databases 89 ■Chapter 6: Working with Users 115 ■Chapter 7: Working with Nodes 137 ■Chapter 8: Working with Fields 163 ■Chapter 9: The Theme System 185 ■Chapter 10: Working with Blocks 223 ■Chapter 11: The Form API 239 ■Chapter 12: Manipulating User Input: The Filter System 295 ■Chapter 13: Searching and Indexing Content 307 ■Chapter 14: Working with Files 323 ■ CONTENTS AT A GLANCE iv ■Chapter 15: Working with Taxonomy 343 ■Chapter 16: Caching 365 ■Chapter 17: Sessions 379 ■Chapter 18: Using jQuery 389 ■Chapter 10: Localization and Translation 417 ■Chapter 20: XML-RPC 451 ■Chapter 21: Writing Secure Code 465 ■Chapter 22: Development Best Practices 487 ■Chapter 23: Optimizing Drupal 499 ■Chapter 24: Installation Profiles 525 ■Chapter 25: Testing 545 ■Appendix A: Database Table Reference 565 ■Appendix B: Resources 623 Index 631 v Contents Foreword xxv About the Authors xxvi About the Technical Reviewers xxvii Acknowledgments xxviii Introduction xxix ■Chapter 1: How Drupal Works 1 What Is Drupal? 1 Technology Stack 1 Core 2 Administrative Interface 3 Modules 3 Hooks 5 Themes 5 Nodes 6 Fields 6 Blocks 6 File Layout 6 Serving a Request 9 The Web Server’s Role 9 The Bootstrap Process 10 ■ CONTENTS vi Processing a Request 10 Theming the Data 11 Summary 11 ■Chapter 2: Writing a Module 13 Creating the Files 13 Implementing a Hook 15 Adding Module-Specific Settings 17 Defining Your Own Administration Section 25 Presenting a Settings Form to the User 26 Validating User-Submitted Settings 29 Storing Settings 29 Using Drupal’s variables Table 29 Retrieving Stored Values with variable_get() 30 Further Steps 30 Summary 31 ■Chapter 3: Hooks, Actions, and Triggers 33 Understanding Events and Triggers 33 Understanding Actions 35 The Trigger User Interface 35 Your First Action 38 Assigning the Action 39 Changing Which Triggers an Action Supports 40 Using the Context in Actions 45 How the Trigger Module Prepares the Context 45 Changing Existing Actions with action_info_alter() 46 Establishing the Context 47 ■ CONTENTS vii How Actions Are Stored 49 The actions Table 49 Action IDs 49 Calling an Action Directly with actions_do() 50 Defining Your Own Triggers with hook_trigger_info() 51 Adding Triggers to Existing Hooks 54 Summary 55 ■Chapter 4: The Menu System 57 Callback Mapping 57 Mapping URLs to Functions 57 Creating a Menu Item 61 Page Callback Arguments 64 Page Callbacks in Other Files 67 Adding a Link to the Navigation Block 68 Menu Nesting 69 Access Control 70 Title Localization and Customization 72 Defining a Title Callback 72 Wildcards in Menu Items 74 Basic Wildcards 74 Wildcards and Page Callback Parameters 75 Using the Value of a Wildcard 75 Wildcards and Parameter Replacement 77 Passing Additional Arguments to the Load Function 78 Special, Predefined Load Arguments: %map and %index 79 Building Paths from Wildcards Using to_arg() Functions 79 Special Cases for Wildcards and to_arg() Functions 79 ■ CONTENTS viii Altering Menu Items from Other Modules 80 Altering Menu Links from Other Modules 82 Kinds of Menu Items 82 Common Tasks 84 Assigning Callbacks Without Adding a Link to the Menu 85 Displaying Menu Items As Tabs 85 Hiding Existing Menu Items 87 Using menu.module 87 Common Mistakes 88 Summary 88 ■Chapter 5: Working with Databases 89 Defining Database Parameters 89 Understanding the Database Abstraction Layer 90 Connecting to the Database 91 Performing Simple Queries 92 Retrieving Query Results 93 Getting a Single Value 94 Getting Multiple Rows 94 Using the Query Builder and Query Objects 94 Getting a Limited Range of Results 95 Getting Results for Paged Display 96 Other Common Queries 97 Inserts and Updates with drupal_write_record() 98 The Schema API 99 Using Module .install Files 100 Creating Tables 100 Using the Schema Module 102 Field Type Mapping from Schema to Database 103 [...]... 470 Using filter_xss_admin() 472 Handling URLs Securely 472 Making Queries Secure with db_query() 473 Keeping Private Data Private with hook_query_alter() 476 Dynamic Queries 477 Permissions and Page Callbacks 477 Cross-Site Request Forgeries (CSRF) 478 File Security 478 File Permissions 479 Protected... hook_form_alter() 263 Submitting Forms Programmatically with drupal_ form_submit() 265 Dynamic Forms 265 Form API Properties 273 Properties for the Root of the Form 273 Properties Added to All Elements 274 Properties Allowed in All Elements 275 Form Elements 277 Summary 293 ■Chapter 12: Manipulating... at that time was a developer book for Drupal Since then, Pro Drupal Development has made an incredible contribution to Drupal s steady growth I don’t think I know a single Drupal developer who doesn’t own a copy of the Pro Drupal Development book Drupal, through its open source nature, has become much greater than I ever imagined it would What didn’t change is the Drupal developer community’s healthy... senior Drupal advisor at Acquia, Inc., a permanent member of the Drupal Association, and a founding member of Die DrupalInitiative, Germany’s Drupal- oriented nonprofit He is active as a module maintainer, core contributor, and speaker at various Drupal events and conferences His Apress projects include Building Online Communities with Drupal, phpBB, and WordPress (author, 2005), Pro Drupal Development. .. that the previous Pro Drupal Development books went out of date Fortunately, the third edition of this book fixes all that This book covers all of the capabilities and developer facilities in Drupal 7, and provides deep insight into the inner workings and design choices behind Drupal 7 Armed with this book and a copy of Drupal s source code, you have everything you need to become a Drupal expert If,... contributors have patches included in Drupal 7 core Drupal 7 will feature some of the biggest architectural changes in the history of Drupal, will ship with many API improvements, and will be able to power bigger sites than ever before The net result is that Drupal 7 is an even better web application development platform than Drupal 6, and it will fuel a lot of Drupal s growth over the next years All these... web development, and to provide web developers an almost infinite amount of flexibility Change is a constant in the Drupal community and key to our success A lot of the success of Drupal today can be attributed to Drupal 6 However, from the day that Drupal 6 was released almost three years ago, we’ve been working really hard on Drupal 7 More than 800 individual contributors have patches included in Drupal. .. to keep Drupal secure by responding to threats and issuing security updates A nonprofit organization called the Drupal Association supports Drupal by improving the drupal. org web site infrastructure and organizing Drupal conferences and events And a thriving online community of users, site administrators, designers, and web developers works hard to continually improve the software; see http:/ /drupal. org... CHAPTER 1 ■■■ How Drupal Works In this chapter, I’ll give you an overview of Drupal Details on how each part of the system works will be provided in later chapters Here, we’ll cover the technology stack on which Drupal runs, the layout of the files that make up Drupal, and the various conceptual terms that Drupal uses, such as nodes, hooks, blocks, and themes What Is Drupal? Drupal is used to build... Drupal Development (technical reviewer, 20 07) , and Pro Drupal Development, Second Edition (technical reviewer, 2008) ■Peter M Wolanin has been working with Drupal since late 2005, when a friend who had been a Howard Dean supporter involved him in a project to build a new Web presence for the local Democratic Party club, and they started building the site on Drupal 4 .7 beta Peter soon became as interested . version ISBN 978 -1-4302-2838 -7 9 78 1430 2283 87 54999 Todd Tomlinson, Author of Beginning Drupal 7 BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® THE EXPERT’S VOICE ® IN OPEN SOURCE Pro Drupal 7 Development . Development/ PHP User level: Intermediate–Advanced THE APRESS ROADMAP Beginning Drupal 7 Foundation Drupal 7 Pro Drupal 7 Development Pro Drupal 7 for Windows Developers www.apress.com SOURCE CODE ONLINE Companion. Submitting Forms Programmatically with drupal_ form_submit() 265 Dynamic Forms 265 Form API Properties 273 Properties for the Root of the Form 273 Properties Added to All Elements 274 Properties

Ngày đăng: 02/08/2014, 09:21

TỪ KHÓA LIÊN QUAN

w