Book Image

Mastering TypoScript: TYPO3 Website, Template, and Extension Development

Book Image

Mastering TypoScript: TYPO3 Website, Template, and Extension Development

Overview of this book

Free, open-source, flexible, and scalable, TYPO3 is one of the most powerful PHP content management systems. It is well suited for creating intranets and extranets for the enterprise. While providing an easy-to-use web interface for non-technical authors and editors of content, its messaging and workflow system enable shared authoring and collaboration. TYPO3 provides flexible and powerful interfaces for both content editors and administrators, giving them full control of the core aspects the system. However for developers who need to customize the system, TYPO3 offers a powerful configuration language called TypoScript. Good knowledge of TypoScript is really a prerequisite for implementing complex applications with TYPO3 and gives developers full control over the configuration of TYPO3 and its template engine. TypoScript enables the complete output template to be created and manipulated, giving you full control over the layout of the site. TypoScript also allows you to integrate dynamic contents, JavaScript-based menus, Flash, Graphics, etc. with ease. You have maximum control over the design of the website and can control all options that would otherwise be addressed by HTML-simple text output, formatting, and much more. TypoScript also allows you to generate graphics at run time and display different content dynamically.
Table of Contents (19 chapters)
Mastering TypoScript: TYPO3 Website, Template, and Extension Development
Credits
About the Author
Preface

The Power of TypoScript


Unlike many other CMSs, TypoScript goes much beyond allowing you to integrate dynamic contents. Thanks to TypoScript, JavaScript-based menus, Flash, Graphics, etc. can be integrated with ease. You have maximum control over the design of the website and can control all options that would otherwise be addressed by HTML—simple text output, formatting, and much more. TypoScript also allows you to generate graphics at run time and the display of content can be changed according to the time of day or the user group.

What does this multiplicity of functions mean to you? To begin with it saves you time learning TypoScript. Even though TypoScript is only a declarative programming language, you first have to get familiar with the syntax. Luckily, TypoScript is not as complex as PHP or Java. Although the ambitious TYPO3 developer may find this to be a limitation in some areas, this reduces potential errors. If you have developed complex menus via JavaScript, you know about the problems that crop up until the menu finally works reliably. For example, take a look at a really simple drop-down menu as used on numerous websites.

<script type="text/javascript"> <!--
function MM_jumpMenu(targ,selObj,restore)
{ //v3.0 eval(targ+".location='"+selObj.options[selObj. selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script>
<form name="demo" method="post" action=""> <select name="themes" onChange="MM_jumpMenu('parent',this,0)"> <option selected>Please choose!</option> <option value="page_one.html">Page 1</option> <option value="page_two.html">Page 2</option> <option value="page_three.html">Page 3</option> <option value="page_four.html">Page 4</option> </select> </form>

This example illustrates some of the aspects and problems of JavaScript menus. If you want to create this type of menu, you have to understand JavaScript. Furthermore, you must have experience as to what browser the syntax works with and how to compensate for functions that create errors in others. Don't forget that this is a really simple example. When we approach dynamic websites, the effort and the likelihood of errors increase. If, for example, you want to provide semi-transparent navigation using graphics and layers, you have to have a thorough knowledge of HTML, DHTML, and JavaScript. The size of such scripts quickly bloats up to several hundred lines. It therefore takes some time before everything is running properly. The debugging adds to the difficulties. How does TypoScript circumvent these? What are its strengths? Take a look at the following menu:

page.10.marks.MENU.1 = GMENU page.10.marks.MENU.1.expAll = 1 page.10.marks.MENU.1.NO
{ backColor = #000000 XY = 100, 20 10 = TEXT 10.text.field = title 10.fontColor = #ffffff 10.offset = 4,14 10.fontFile = fileadmin/verdana.ttf 10.fontSize = 11 wrap = | <br /> } page.10.marks.MENU.2 = GMENU page.10.marks.MENU.2.NO
{ backColor = #c0c0c0 XY = 100, 20 10 = TEXT 10.text.field = title 10.fontColor = #ffffff 10.offset = 4,14 10.fontFile = fileadmin/verdana.ttf 10.fontSize = 10 wrap = | <br /> }

This is how menus are created in TypoScript. The example shown is representative of the size of scripts that create menus. Even graphical menus can be created with scripts of this length and the syntax is much simpler than that of JavaScript.

Obviously menus are not the only area where TypoScript helps developers. Have you ever used PHP to create run time graphics? The experienced PHP developer doesn't usually have a problem with this, but the creation of a corresponding script requires a lot of development and testing time. With TypoScript this is no problem even for those with no PHP experience.