Drupal 7 FieldsCCK beginner's guide (2011)

288 558 2
Drupal 7   FieldsCCK   beginner's guide (2011)

Đ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

học drupal CCK

Drupal Fields/CCK Beginner's Guide Explore Drupal fields/CCK and master their use Dave Poon BIRMINGHAM - MUMBAI Drupal Fields/CCK Beginner's Guide Copyright © 2011 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 2011 Production Reference: 1050711 Published by Packt Publishing Ltd 32 Lincoln Road Olton Birmingham, B27 6PA, UK ISBN 978-1-849514-78-1 www.packtpub.com Cover Image by Rakesh Shejwal (shejwal.rakesh@gmail.com) Credits Author Dave Poon Reviewers Maurice Green, PhD Project Coordinator Michelle Quadros Proofreader Kevin McGowan Abdul Hafeez Dan Stefan Poka Indexer Tejal Daruwale Acquisition Editor Usha Iyer Graphics Nilesh Mohite Development Editor Neha Mallik Production Coordinator Aparna Bhagat Technical Editor Vanjeet D'souza Cover Work Aparna Bhagat Copy Editor Neha Shetty About the Author Dave Poon is a web developer and designer based in Sydney He started his career as a freelance graphic and web designer in 1998 and works with web development agencies and medium sized enterprises He graduated from Central Queensland University with a degree in Multimedia Studies and a Master's degree in IT His love affair with Drupal began afterwards, and he now works for a variety of companies using Drupal He is the founder and Technical Director of Erlango (http://erlango.com), a web product development startup, located in Sydney and Hong Kong, which uses Drupal as a framework to create web products and customized CMS He is also the technical reviewer of Drupal Intranets with Open Atrium by Tracy Smith (Packt Publishing, 2011) I would like to thank my wife Rita (she should be my wife at the time of the printing of this book) for her endless patience and support Without her, what I would be meaningless I would also like to thank my father for his continued encouragement It is my great fortune to have worked with a great team of publishing professionals at Packt Publishing I extend my sincerest gratitude to Usha Iyer, Neha Mallik, Vanjeet D'souza, Neha Shetty, and Michelle Quadros for their cooperation and help in writing this book About the Reviewers Maurice Green (PhD) began his love affair with computers in 1963 as a graduate student in biochemistry using Fortran and punch cards Retiring after a 40 year career as a medical laboratory director specializing in automated laboratory instrumentation and information systems and an IT manager in the Department of Medicine at Stanford University, he turned his attention to photography, video editing, and web design He is currently the president of the Silicon Valley Computer Society and leads the Web Design special interest group He is the developer and webmaster for the Silicon Valley Computer Society website (http://svcs.net/) He presented several talks at the Design Drupal conference at Stanford He was the reviewer for Drupal First Look by Mark Noble (Packt Publishing, 2010) Abdul Hafeez is a professional software developer, technology consultant, and an avid Drupal user as well as developer He has completed his Bachelor's degree in Information Technology Abdul has spent a number of years in the development of software projects specifically in Drupal He has provided patches and support for many contributed Drupal modules and has been involved with the Drupal community since 2008 He has developed and maintained many custom modules for clients Abdul's Drupal user account (rightchoice2c_me) can be found at http://drupal.org/user/315349 Abdul is focused on the integration and interoperability of different technologies, especially ones related to PHP, Ruby on Rails, and the web He is an active member in the open source community, especially in Drupal I would like to thank my parents and my friends, for their encouragement and for giving me time to pursue and support Drupal-related tasks, including reviewing this book Dan Stefan Poka is an avid Drupal developer, active mainly in the London (UK) area, with roughly three years' Drupal experience, having been involved in the community since Drupal He acquired this experience by working in small teams and big teams alike and technologies as different as Ubercart and ApacheSolr He feels comfortable taking on all parts of Drupal development from module development to theme development His first experience in reviewing was for the well known Pro Drupal Development (Second Edition) from Apress by sending corrections to code examples, all of which made it into the book's errata I would like to thank my colleagues from whom I've learned a lot, and my family for their patience 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 service@packtpub.com 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? ‹‹ Fully searchable across every book published by Packt ‹‹ Copy and paste, print and bookmark content ‹‹ 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 Chapter 1: Nodes and Content types in Drupal The book example project A preview of the final project What is a content type? Default content types in Drupal core The Basic page content type The Article content type Time for action – creating contents using the article content type Creating custom content types Creating the Cooking Tip content type Time for action – creating the Cooking Tip content types Creating the Recipe content type Time for action – creating the Recipe content type Adding content using custom content types Adding content using the Cooking Tip content type Time for action – adding content using the Cooking Tip content type Adding content using the Recipe content type Time for action – adding contents using the Recipe content type Summary Chapter 2: Fields What is CCK? Fields in Drupal Enabling the Field module Time for action – enabling the Field module Field, Field UI, and Field SQL storage modules Time for action – finding the Field UI Field types and input widgets 8 13 14 15 16 16 20 20 20 24 25 27 27 27 30 30 32 33 33 35 35 35 37 38 40 Appendix Pop quiz – formatting comment field display Question number Answer b Pop quiz – formatting vocabulary field display Question number Answer b Chapter 7, Contributed Field Modules Pop quiz – finding a contributed field module Question number Answer b b Pop quiz – installing and enabling contributed modules Question number Answer b c Chapter 8, Field Level Permissions Pop quiz – installing and enabling the Field Permission module Question number Answer b [ 257 ] Pop Quiz Answers Pop quiz – enabling field-level permissions Question number Answer c b Pop quiz – configuring field-level permissions on the PERMISSIONS administration page Question number Answer a b Pop quiz – the Field permissions report page Question number Answer a Chapter 9, Theming Fields Pop quiz – creating a Drupal theme by cloning the existing theme Question number Answer b b b Pop quiz – creating a template file for the Recipe content type Question number Answer c [ 258 ] Appendix Pop quiz – editing a template file Question number Answer c b Pop quiz – styling the page using CSS Question number Answer b a Chapter 10, A Database Perspective of Fields Pop quiz – key elements in Fields Question number Answer c b b Pop quiz – new concepts in Drupal Question number Answer c a [ 259 ] Pop Quiz Answers Pop quiz – creating a new content type Question number Answer c Pop quiz – a database perspective of fields Question number Answer a c [ 260 ] Index A Add content link 108 Add vocabulary link 94 Allowed file extensions settings 127 Amazon S3 226 API 37 Application Programming Interface See  API Article content type about 10, 14, 16, 34 content, creating with 16-19 B Basic page content type 14, 15, 34 BBCode filter module 15 Body field display formatting, in teaser view 153-156 book example project Boolean fields adding 72-74 bundle 226 C Cascading Style Sheet See  CSS CCK module about 33, 232 URL, for downloading 35 comment field display formatting 163, 164 comments fields, adding to 55 fields, creating for 63 text fields, adding to 55-57 Computed field module 185 Contemplate module 185 content adding, with Cooking Tip content type 27-30 adding, with custom content types 27 adding, with Recipe content type 30, 31 categorizing, Recipe Category vocabulary used 113 categorizing, taxonomy used 108-112 creating, with article content type 16-19 Content Construction Kit See  CCK module content_node_field_instance table 232 content_node_field table 232 Content Profile module 230 Content Templates module See  Contemplate module content.txt file 17, 28 content type about 10, 13, 14, 232 article 10, 16 basic page 15 cooking tip 11, 12, 20-24 creating 234-237 fields, adding to 46 fields, creating for 63 file field, adding to 120 file fields, configuring for 120 image fields, adding to 133 recipe 11-13, 24, 26 term references, adding to 102-107 content_type_recipe table 232 content types contributed field modules computed field 185 contemplate 185 email field 184 link 185 table field 185 contributed modules, Drupal about 170 searching 171 searching, through drupalmodules.com website 173-175 searching, through Drupal website 171-173 cooking method category 92 Cooking Tip Category vocabulary creating 94, 95 field, adding to 113-117 terms, adding to 98-102 Cooking Tip content type about 11, 12 categorizing, taxonomy used 108-112 content, adding with 27-30 creating 20-24 fields 34 file field, adding to 128 file field, configuring for 128 image field, adding to 141 term reference field, adding to 103-107 Cooking Tip link 108 cooking website about homepage 10 core modules, Drupal about 42 file 45 image 45 list 44 number 42 taxonomy 44 text 43 CouchDB 226 CSS about 221 webpage, styling with 221-223 custom content types content, adding with 27 creating 20 custom display settings Full content view mode, enabling in 158, 159 custom fields 34 custom image styles creating 141-145 D database schema 229 default content types 19 default values setting 75-77 Devel module 212 Difficulty level option 13 downloading Field Permission module 188, 189 Drupal advantages 169 contributed modules, searching 171 modules 170 theme 204 theming 204 webpage, rendering in 205, 206 Drupal 119 Drupal about 8, 119 Boolean fields, adding 72-74 comment field display, formatting 163, 164 content, categorizing with taxonomy 108-112 content types 13, 14 core modules 42-45 custom image styles, creating 141-145 default values, setting 75-77 Field API 225 field display 148 field display, formatting in teaser view 153-156 field display settings 148-152 Field module, enabling 35, 37 fields 35 fields, adding to vocabularies 113-117 Field SQL storage module 37 Field UI, searching 38, 39 file fields, adding to content types 120 file fields, configuring for content types 120 file fields, using 128-132 file module 120 Full content view mode, enabling in custom display settings 158, 159 image field display, formatting on Full content view mode 160-163 image fields, adding to content types 133 image fields settings, configuring 135 [ 262 ] list fields, adding 78-83 multiple values, enabling 65-71 multiple value widgets 83 taxonomy 91 term references, adding to content type 103107 terms, adding to vocabularies 98-102 vocabularies, creating 93-97 vocabulary field display, formatting 165, 166 Drupal developers 169 drupalmodules.com website contributed field modules, searching through 173-175 Drupal theme creating 207 creating, by cloning existing theme 207-211 Drupal website contributed field modules, searching through 171-173 Drush 170 E edit vocabulary link 114 Email field order, rearranging for 58, 62, 63 Email field module about 184 features 184 installing 176-179 Email text field reusing, in Recipe content type 62 entities 226, 230, 231 everything is a node concept 230 existing fields reusing 59 F fieldable entities 227 Field API 225 field_config_entity_type table 239 field_config_instance table 240 field_config table 238 field configuration information 238 field_data_body table 240, 241 field_data_comment_body 241 field_data_field_(filefield_name) table 244 field_data_field_image table 242 field_data_field_tags table 242, 243 field_data_taxonomy_forums table 243 field display about 148 formatting, in teaser view 153-156 settings 148-152 field formatters 227 field instances 227 field-level permissions configuring, on PERMISSIONS administration page 196-198 enabling 192-194 Field module about 35, 37, 169 enabling 35, 37 Field Permission module downloading 188, 189 enabling 190, 191 field-level permissions, enabling 192-194 Field permissions report page 199-201 installing 190, 191 Field permissions report page 199-201 field related database tables about 240 field_config_instance 240 field_data_body 240, 241 field_data_comment_body 241 field_data_field_(filefield_name) 244 field_data_field_image 242 field_data_field_tags 242, 243 field_data_taxonomy_forums 243 field_revision_body 244 field_revision_comment_body 245, 246 field_revision_field_file 248 field_revision_field_image 246 field_revision_field_tags 247 field_revision_taxonomy_forums 247 file_managed 249 field_revision_body table 244 field_revision_comment_body table 245, 246 field_revision_field_file table 248 field_revision_field_image table 246 field_revision_field_tags table 247 field_revision_taxonomy_forums table 247 [ 263 ] fields about 8, 35, 227, 232, 238 adding, to comments 55 adding, to content types 46 adding, to Cooking Tip Category vocabulary 113-117 adding, to vocabularies 113-117 creating, for comments 63, 118 creating, for content types 63, 118 existing fields, reusing 59 order, rearranging for 53 Field SQL storage module 37 field storages 226 field types about 226 searching, in Field UI module 40, 41 Field UI module field types, searching in 40, 41 input widgets, searching in 40, 41 searching 38, 39 field widgets 227 file field adding, to content type 120 adding, to Cooking Tip content type 128 adding, to Recipe content type 120-127 configuring, for content types 120 configuring, for Cooking Tip content type 128 configuring, for Recipe content type 120-127 using 128-132 file_managed table 249 File module 45, 120 Full content view mode enabling, in custom display settings 158, 159 image field display, formatting on 160-163 images directory 17 input widgets searching, in Field UI module 40, 41 installation, Email field module 176-179 installing Email field module 176-179 Field Permission module 190, 191 Link module 180-183 K key elements, for fields about 226 bundle 226 entities 226 field 227 fieldable entities 227 field formatters 227 field instances 227 field storages 226 field types 226 field widgets 227 taxonomy 228 L Link module about 185 installing, Update manager used 180-183 list fields adding 78-83 list module 44 long text field adding, with text module 46-50 M I image field adding, to content types 133 adding, to Cooking Tip content type 141 adding, to Recipe content type 134, 135 configuring, for Recipe content type 136-140 settings, configuring 135 image field display formatting, on Full content view mode 160-163 image module 45 images 119 manage fields page 41 Markdown filter module 15 modules directory 177 modules, Drupal 170 MongoDB 226 multiple values enabling 65-71 multiple value widgets about 83 changing 84, 85 [ 264 ] file field, adding to 120-127 file field, configuring for 120-127 image field, adding to 134, 135 image field, configuring for 136-140 Notes field, reusing for 59, 60 Source field, reusing for 60, 61 template file, creating for 212-214 term reference, adding to 108 check boxes/radio buttons widget, switching to 87-89 number of values, changing 86, 87 N new content type creating 234-237 node 13, 229 Node Comments module 230 node recipe.tpl.php template file 214 node_revision table 232 node_type table 233 Notepad++ 214 Notes field order, rearranging for 53, 55, 61 reusing, for Recipe content type 59, 60 number module 42 S salad.jpg file 17 Save and add fields button 23 Save settings button 106 Source field reusing, for Recipe content type 60, 61 starter theme 207 sub-theme 207 O T object 229 objects are not entities concept 231 order rearranging, for Email field 58, 62, 63 rearranging, for fields 53 rearranging, for Notes field 53, 55, 61 Table field module 185 taxonomy about 91, 228 Cooking Tip Content, categorizing with 108-112 example 92, 93 taxonomy module 44 Taxonomy term pages 113 teaser view about 153 Body field display, formatting in 153-156 field display, formatting in 153-156 template files craeting, for Recipe content type 212-214 editing 214-220 overriding 212 term reference field adding, to Cooking Tip content type 103-107 term references adding, to content types 102-107 adding, to Recipe content type 108 terms about 92, 93 adding, to Cooking Tip Category vocabulary 98-102 adding, to Recipe Category vocabulary 102 adding, to vocabularies 98-102 P PERMISSIONS administration page field-level permissions, configuring on 196-198 PHP filter module 15 phpMyAdmin 235 R Recipe Category vocabulary about 93 content, categorizing with 113 creating 96, 97 terms, adding to 102 Recipe content type about 11-13, 24 content, adding with 30, 31 creating 25, 26 Email text field, reusing in 62 fields 34 [ 265 ] text areas 46 text fields adding, to comments 55-57 adding, with text module 46, 51, 52 Textmate 214 text module about 43 long text field, adding with 46-50 text fields, adding with 46, 51, 52 theme about 204 visual elements 204 theming about 204 options 206 V U webpage rendering, in Drupal 205, 206 styling, CSS used 221-223 Update manager Field Permission module, using with 190, 191 Link module, installing with 180-183 view modes, for custom display settings 159 vocabularies about 92, 93 Cooking Tip Category vocabulary, creating 94, 95 creating 93-97 fields, adding to 113-117 Recipe Category vocabulary, creating 96, 97 terms, adding to 98-102 vocabulary field display formatting 165, 166 W [ 266 ] Thank you for buying Drupal Fields/CCK Beginner's Guide About Packt Publishing Packt, pronounced 'packed', published its first book "Mastering phpMyAdmin for Effective MySQL Management" in April 2004 and subsequently continued to specialize in publishing highly focused books on specific technologies and solutions Our books and publications share the experiences of your fellow IT professionals in adapting and customizing today's systems, applications, and frameworks Our solution based books give you the knowledge and power to customize the software and technologies you're using to get the job done Packt books are more specific and less general than the IT books you have seen in the past Our unique business model allows us to bring you more focused information, giving you more of what you need to know, and less of what you don't Packt is a modern, yet unique publishing company, which focuses on producing quality, cutting-edge books for communities of developers, administrators, and newbies alike For more information, please visit our website: www.packtpub.com About Packt Open Source In 2010, Packt launched two new brands, Packt Open Source and Packt Enterprise, in order to continue its focus on specialization This book is part of the Packt Open Source brand, home to books published on software built around Open Source licences, and offering information to anybody from advanced developers to budding web designers The Open Source brand also runs Packt's Open Source Royalty Scheme, by which Packt gives a royalty to each Open Source project about whose software a book is sold Writing for Packt We welcome all inquiries from people who are interested in authoring Book proposals should be sent to author@packtpub.com If your book idea is still at an early stage and you would like to discuss it first before writing a formal book proposal, contact us; one of our commissioning editors will get in touch with you We're not just looking for published authors; if you have strong technical skills but no writing experience, our experienced editors can help you develop a writing career, or simply get some additional reward for your expertise Drupal ISBN: 978-1-849512-86-2 pages Paperback: 416 Create and operate any type of Drupal website quickly and efficiently Set up, configure, and deploy a Drupal website Easily add exciting and powerful features Design and implement your website's look and feel Promote, manage, and maintain your live website Drupal Theming Cookbook ISBN: 978-1-84719-868-6 Paperback: 384 pages Over 100 clear step-by-step recipes to create powerful, great-looking Drupal themes Take control of the look and feel of your Drupal website Tips and tricks to get the most out of Drupal's theming system Learn how to customize existing themes and create unique themes from scratch Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible Please check www.PacktPub.com for information on our titles Drupal Module Development ISBN: 978-1-849511-16-2 Paperback: 420 pages Create your own Drupal modules from scratch Specifically written for Drupal development Write your own Drupal modules, themes, and libraries Discover the powerful new tools introduced in Drupal Learn the programming secrets of six experienced Drupal developers Drupal Web Services ISBN: 978-1-84951-098-1 Paperback: 320 pages Integrate social and multimedia Web services and applications with your Drupal Web site Explore different Web services and how they integrate with the Drupal CMS Reuse the applications without coding them again using the Web services protocols on your Drupal site Configure your Drupal site to consume various web services by using contributed Drupal modules for each specific task or application Drive the content from your Drupal site to Facebook, Twitter and LinkedIn using effective Drupal Web services Please check www.PacktPub.com for information on our titles Drupal Themes ISBN: 978-1-847195-66-1 pages Paperback: 312 Create new themes for your Drupal site with clean layout and powerful CSS styling Learn to create new Drupal themes No experience of Drupal theming required Techniques and tools for creating and modifying themes A complete guide to the system's themable element Drupal Social Networking ISBN: 978-1-847196-10-1 pages Paperback: 312 Build a social or community web site, with friends lists, groups, custom user profiles, and much more Step-by-step instructions for putting together a social networking site with Drupal Customize your Drupal installation with modules and themes to match the needs of almost any social networking site Allow users to collaborate and interact with each other on your site Please check www.PacktPub.com for information on our titles Drupal Performance Tips ISBN: 978-1-847195-84-5 pages Paperback: 240 Learn how to maximize and optimize your Drupal framework using Drupal best practice performance solutions and tools Monitor the performance of your Drupal website and improve it Configure a Drupal multisite environment for best performance Lot of examples with clear explanations Choose and use the best Drupal modules for improving your site's performance Drupal Site Builder Solutions ISBN: 978-1-847196-40-8 Paperback: 352 pages Build powerful website features for your business and connect to your customers through blogs, product catalogs, newsletters, and maps Implement the essential features of a business or non-profit website using Drupal Integrate with other "web 2.0" sites such as Google Maps, Digg, Flickr, and YouTube to drive traffic, build a community, and increase your website's effectiveness No website development knowledge required Please check www.PacktPub.com for information on our titles ... (Contemplate) module Summary Chapter 8: Field Level Permissions 170 170 171 171 173 176 176 180 184 184 185 185 185 185 185 1 87 Downloading the Field Permission module Time for action – downloading... action – checkboxes/radio buttons widget with multiple values Summary [ ii ] 65 66 72 72 75 75 78 78 83 86 87 90 Table of Contents Chapter 4: Taxonomy 91 What is taxonomy? Creating vocabularies.. .Drupal Fields/CCK Beginner''s Guide Explore Drupal fields/CCK and master their use Dave Poon BIRMINGHAM - MUMBAI Drupal Fields/CCK Beginner''s Guide Copyright © 2011 Packt

Ngày đăng: 02/07/2013, 15:31

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan