Mastering Typoscript: TYPO3 Website, Template, and Ebsite, T Extension Development
Total Page:16
File Type:pdf, Size:1020Kb
TYPO3 W Mastering T Mastering TypoScript: TYPO3 Website, Template, and ebsite, T Extension Development TypoScript is a declarative configuration language that offers developers, administrators, and emplate, and Extension Development designers full control over the configuration of TYPO3 and its template engine. Only with a good command of TypoScript can you leverage the powerful capabilities of the TYPO3 engine to customize and control all aspects of your TYPO3 sites. In this book, Daniel Koch provides you with all the information needed to master TypoScript in a ypoScript clear and practical way with many examples to develop your skills. Written in a clear, easy-to-read style, the book provides step-by-step instructions on using TypoScript for TYPO3 website development, template and extension development, and back-end and front-end administration. What you will learn from this book • Design and develop templates in TYPO3—design templates, pure TypoScript templates, and TemplaVoilà • Develop extensions in TYPO3; build extensions using Kickstarter From Technologies to Solutions • Understand the objects, properties, operators, and datatypes in TypoScript • Understand the entire TYPO3 back end, including the Info/Modify tool, the Object browser, the Template Analyzer, and the TypoScript Properties display • Work with design templates using markers, subparts, and HTML comments • Understand how to present different views of content with different menu entry types • Understand TYPO3 database structure and query it using SQL • Use user groups to distribute the editing and management of content on your site Mastering TypoScript • Customize the back end with Page TSConfig and User TSConfi g TYPO3 Website, Template, and Extension Development Who this book is written for Daniel Koch This book is suitable for TYPO3 developers, administrators, and designers who want to develop fully featured TYPO3 websites using the power of TypoScript. A basic knowledge of TYPO3 is expected, and PHP and MySQL programming experience is useful, though not A complete guide to understanding and using TypoScript, essential for using this book. TYPO3’s powerful confi guration language $ 49.99 US Packt Publishing £ 30.99 UK Birmingham - Mumbai € 44.99 EU www.packtpub.com Prices do not include local sales tax or VAT where applicable Daniel Koch Mastering TypoScript: TYPO3 Website, Template, and Extension Development A complete guide to understanding and using TypoScript, TYPO3's powerful configuration language Daniel Koch BIRMINGHAM - MUMBAI Mastering TypoScript: TYPO3 Website, Template, and Extension Development Copyright © 2006 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, 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: December 2006 Production Reference: 3141206 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 1-904811-97-3 www.packtpub.com Cover Image by www.visionwt.com Copyright © 2005 Carl Hanser Verlag, Munich/FRG All rights reserved. Authorized translation from the original German language edition published by Carl Hanser Verlag, Munich/FRG. Credits Author Project Manager Daniel Koch Patricia Weir Development Editor Indexer Louay Fatoohi Bhushan Pangaonkar Translator Proofreader Wolfgang Spegg Chris Smith Technical Editor Layouts and Illustrations Ashutosh Pande Shantanu Zagade Editorial Manager Cover Designer Dipali Chittar Shantanu Zagade About the Author Daniel Koch is a freelancing author and developer. His main focus is on Open Source Web Applications and Content Management Systems. Daniel lives in Hamburg, Germany. He has authored/coauthored eighteen books and frequently contributes to IT magazines. His website is http://www.medienwerke.de/. Thanks to Sarah for the last 11 years, which have been wonderful. Table of Contents Preface 1 Chapter 1: Introduction to TypoScript 7 Prerequisites 7 Dummy Package 7 Setting up an Example Page Structure 7 Declarative Programming with TypoScript 10 The Power of TypoScript 10 What is TypoScript? 12 Back-end Configuration with TypoScript 13 TypoScript and PHP 13 TypoScript Templates 16 Summary 18 Chapter 2: Getting to Know TypoScript 19 Hello World! 19 Creating a Template 19 Syntax 22 Objects and Properties 22 Copying Objects and Properties 24 Referencing Objects 26 Classic Sources of Errors 27 The Classification of Objects 28 Constants 28 Operators 29 Value Assignment 29 Value Assignment over Several Lines 29 The Copy and Delete Operators 30 Referencing 30 Conditions 30 Table of Contents Faster Writing Through {} 31 Datatypes 32 Simple Datatypes 32 Objects as Datatypes 33 Functions as Datatypes 33 The Wrap Principle 34 Comments 35 Conditions 35 The ELSE Condition 36 Extended Options 36 Defining Your Own Conditions 37 Functions 38 Working with TSref 38 Datatypes 39 Objects and Properties 39 Conditions 39 Functions 39 Constants 39 Setup 39 cObjects 39 GIFBuilder 39 MENU Objects 40 Media/Scripts Plug-Ins 40 Standard Templates 40 PHP Include Scripts 40 Casestory 40 Index.php 40 Tips 40 Summary 41 Chapter 3: Tools and Editors 43 Choosing an Editor 43 Syntax Highlighting in UltraEdit 44 The Info/Modify Tool 44 Elements 45 Title 45 Sitetitle 45 Description 46 Resources 46 Constants 46 Setup 46 Editing the Whole Template 46 The Object Browser 47 [ ii ] Table of Contents The Template Analyzer 49 The TypoScript Properties Display 50 The Admin Panel 50 Categories 51 Preview 51 Cache 52 Publish 52 Editing 52 TypoScript 52 The Constant Editor 54 Preparing Constants 54 A Practical Demonstration: Defining Heading Colors through Constants 55 Categories 57 Subcategories 57 Field Types 58 Describing Categories 59 TypoScript in HomeSite 60 HTMLArea RTE 61 Using Your Own CSS Styles 62 Activating and Deactivating Buttons 63 Setting the Permitted Tags 64 Customizing the Color Field 65 Making Additional Functions Available 67 Customizing the Rich-Text Editor (RTE) 68 Configuring the Toolbar 69 Defining Your Own Classes 71 Paragraph Formats 72 Defining Colors 73 User-Defined Menus 74 Modifying the Background Color 75 Managing the Output 76 Preserving <br /> Tags 76 Allowing Additional Tags 76 Summary 77 Chapter 4: Design Templates 79 Design Templates versus Templates 79 Principles of Design Templates 79 Markers 80 Subparts 80 HTML Comments and Subparts 81 Double Headings 82 Summary 84 [ iii ] Table of Contents Chapter 5: Templates 85 The Concept of Templates 85 Hello World! 85 Hello World! Part II 86 Inheriting Templates 87 Template Elements 88 Objects and Properties of Websites 91 Defining Page Properties with TypoScript 91 bodyTag 91 stylesheet 92 meta 92 Integrating Design Templates 92 Activating the Design Template 92 Activating Placeholders 94 Activating Subparts 95 Integrating a Stylesheet 95 Activating Markers 96 Locating Errors 96 The Auto Parser Template 97 Installing the Parser 97 Creating a Sample Application 98 Editing the Settings 98 Standard Templates 102 template 103 temp.* 104 styles 104 records (example) 104 content (default) 105 frameset 105 plugin 105 Pure TypoScript Templates 105 TemplaVoilà 107 System Prerequisites 107 Preparing TemplaVoilà 108 Setting up the Data Structure 109 Creating Content 118 Conclusion 119 Flexforms 119 Summary 119 Chapter 6: Working with Graphics 121 Prerequisites 121 Embedding Graphics 123 [ iv ] Table of Contents Modifying Graphics 123 Changing the Graphic Size 124 Creating Graphics Dynamically 124 GIFBUILDER 125 Levels 127 Positioning Levels 130 Drawing Boxes 130 Graphical Text 131 Anti-Aliasing with niceText 133 Advanced Options 135 Shadows 135 Relief 136 Showing the Page Title as a Graphic 137 Importing Graphics from the Database 138 Caching 139 What is Cached in TYPO3 140 Emptying the Cache 140 Summary 142 Chapter 7: Menus 143 Available Menu Types 143 Hello Menu! 144 Specifying Menu Properties 145 Defining States 145 Defining the Starting Point of a Menu 146 Specifying Menu Types 147 Defining the Entry Level 148 Specifying the First Menu Entry 148 Specifying the Number of Menu Entries 149 Excluding Menu Items 149 Text Menus 149 Properties of Text Menus 150 Defining Sub-Menus 151 Using Stylesheets 151 Spacing between the Menu Items 152 OptionSplit: Adding Vertical Lines 153 Menus and Tables 154 Text Menus and JavaScript 155 JavaScript Menus 156 Calling Pages from the Menu 157 Graphical Menus 158 Creating Menu Items 159 [ v ] Table of Contents Integrating Sub-Menu Items 160 Creating Lines 161 Automatically Customizing the Menu Width 162 Adding Background Graphics 164 An Alternative to GMENU 164 GMENU_FOLDOUT 165 Layer Menus 167 Formatting the Menu 171 Text Menus in Layer Form 174 ImageMaps 174 Special Menus 175 Next Page (Browse Menu) 175 You are Here (Rootline Menu) 176 Keywords Menu 177 Updated Pages 177 Directory Menus 180