1. Trang chủ
  2. » Công Nghệ Thông Tin

pro drupal 7 development 3rd edition

721 461 0
Tài liệu đã được kiểm tra trùng lặp

Đ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 9,71 MB

Nội dung

giáo trình drupal 7, pro drupal 7 development 3rd edition

www.it-ebooks.info www.it-ebooks.info Pro Drupal 7 Development Third Edition ■ ■ ■ Todd Tomlinson John K. VanDyk www.it-ebooks.info 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. www.it-ebooks.info 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 www.it-ebooks.info ■ 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 www.it-ebooks.info 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 www.it-ebooks.info ■ 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 www.it-ebooks.info ■ 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 www.it-ebooks.info ■ 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 www.it-ebooks.info . www.it-ebooks.info Pro Drupal 7 Development Third Edition ■ ■ ■ Todd Tomlinson John K. VanDyk www.it-ebooks.info Pro Drupal 7 Development: Third Edition Copyright. 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

Ngày đăng: 23/08/2013, 09:27

TỪ KHÓA LIÊN QUAN