TYPO3 Extension Development Developer's guide to creating feature-rich extensions using the TYPO3 API Dmitry Dulepov BIRMINGHAM - MUMBAI TYPO3 Extension Development Copyright © 2008 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(s), Packt Publishing, nor its dealers or 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 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: September 2008 Production Reference: 1190908 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847192-12-7 www.packtpub.com Cover Image by Vinayak Chittar ([email protected]) [ FM-2 ] Credits Author Project Manager Dmitry Dulepov Abhijeet Deobhakta Reviewer Project Coordinator Ingo Renner Rajashree Hamine Acquisition Editor Indexers Adil Ahmed Rekha Nair Monica Ajmera Development Editor Nikhil Bangera Proofreader Angie Butcher Technical Editor Dhiraj Bellani Production Coordinators Aparna Bhagat Copy Editor Rajni Thorat Sumathi Sridhar Cover Designer Editorial Team Leader Aparna Bhagat Mithil Kulkarni [ FM-3 ] About the Author Dmitry Dulepov is a TYPO3 core team member and developer of several popular extensions (such as RealURL, TemplaVoila, comments, ratings, and others). He is known by his active support of the TYPO3 community through TYPO3 mailing lists. In 2008 Dmitry won the contest to appear on the first TYPO3 playing cards. He runs a popular blog where he regularly publishes original tips and articles about various TYPO3 features. In addition to his continuous TYPO3 core and extension development, Dmitry provides support for the TYPO3 translation team on behalf of the core team. The author would like to thank everyone who helped with the book. This includes but is not limited to: • Packt Publishing, for their very prompt answering of every question and giving helpful comments. • Ingo Renner, who reviewed the book and made really good additions, notes, and corrections. • My colleagues from Netcreators BV, especially to Ben van 't Ende, who always said that the book is important and Michiel Roos, who gave me some ideas during our work together on a TYPO3 project. • My wife and kids, who understood the importance of this work and supported me in this work; my cats, who reminded me to make breaks and stretch by jumping on my knees in the least expected moments. • To the TYPO3 community, who helped me to understand typically met issues with TYPO3 extension development. The author is sure that the book will be useful to the reader and hopes to see more great extensions from the readers of the book soon. [ FM-4 ] About the Reviewer Ingo Renner has been active in the TYPO3 project for about five years now. He started contributing to the project with a table-less template for the popular news extension "tt_news". Since then he has been active in many other areas including the content rendering group, digital asset management project, and the core team. Besides that, he's also known as a co-development leader for tt_news, current maintainer of tt_address, and lead developer for TYPO3's blog extension TIMTAB. In 2007, he joined the core team and was suddenly charged with the role of the release manager for TYPO3 4.2 - TYPO3's recent release. In March 2008, he graduated from the University of Applied Sciences, Darmstadt, with a Master of Science in Computer Science. Ingo is a freelancer specialized in TYPO3 core development and always looking for interesting projects to improve the TYPO3 core. [ FM-5 ] Table of Contents Preface 1 Chapter 1: About TYPO3 API 5 Overview of TYPO3 API 5 PHP Classes and Files 6 t3lib_ 7 tslib_ 7 tx_ 8 ux_ 8 user_ 9 How Data Is Stored in TYPO3 9 Common TYPO3 API 10 Database API 11 Extension Management 15 Helper Functions (t3lib_div) 16 GET/POST Functions 16 String Functions 17 Array Functions 17 XML Processing 18 File, Directory, and URL Functions 19 Debug Functions 20 System Functions 20 TYPO3-Specific Functions 21 TYPO3 File References 22 Language Support 23 Reference Index 25 Hooks 26 Backend API 26 TCEforms 27 TCEmain 28 Record Manipulation 28 Table of Contents Clearing Cache 31 Frontend API 32 TSFE 32 Content Objects 34 Plugin API 34 Summary 34 Chapter 2: Anatomy of TYPO3 Extension 35 TYPO3 Extension Categories 35 Category: Frontend 36 Category: Frontend plugins 36 Category: Backend 36 Category: Backend module 37 Category: Services 37 Category: Examples 37 Category: Templates 37 Category: Documentation 37 Category: Miscellaneous 38 Extension Files 38 Common Files 38 ext_emconf.php 38 ext_conf_template.txt 44 ext_tables.php 46 ext_tables.sql 49 ext_tables_static+adt.sql 50 ext_localconf.php 50 ext_icon.gif 51 tca.php 51 class.ext_update.php 53 Frontend Plugin Files 54 pi Files 55 TypoScript Templates 55 Backend Module and its Files 56 Module Function Files 57 Documentation Files 58 Summary 58 Chapter 3: Planning Extensions 59 Why is Planning Important? 59 How to Plan 60 Gathering Requirements 61 Implementation Planning 61 Documentation Planning 62 [ ii ] Table of Contents TYPO3-Specific Planning 62 Extension Keys 62 Database Structure 63 Field Names 63 Indexes 66 Database Relations 66 Planning Our Extension 67 Requirements 67 Functionality 67 Usability and Expandability 68 Technical 68 Extension key 69 Frontend Plugins 69 Backend Module 69 Other Classes 70 Extension Database Structure 70 Documentation 72 Summary 72 Chapter 4: Generating Extensions 73 Why Generation? 73 Preparing for Generation 73 Generation Steps 74 Entering an Extension key 75 Entering Extension Information 75 Set Up Languages 77 Creating New Database Tables 77 Extending Existing Tables 85 Creating Frontend Plugins 86 Creating Backend Modules 89 Integrating into Existing Modules 90 Adding Clickmenu Items 90 Creating Services 90 Static TypoScript Code 90 Adding TSConfig 92 Generating the Extension 92 Adjusting Extensions 94 Clean Up 94 Changing Fields 94 Hide Tables 94 Summary 95 [ iii ]
Description: