typoscript 2.0

21
T3CON10 Frankfurt Robert Lemke TypoScript 2.0 Samstag, 2. Oktober 2010

Upload: robert-lemke

Post on 19-May-2015

2.597 views

Category:

Documents


0 download

DESCRIPTION

TYPO3 Phoenix features a revised version of TYPO3’s powerful object definition syntax. The main design goals were consistency, simplicity and extensibility. In this session you’ll learn about the new object-oriented approach, the improved syntax, how you get full control over the rendered output and if stdWrap and friends made it to the next version. The examples from this talk will help you to experiment with your own TypoScripts on your own TYPO3 Phoenix installation.

TRANSCRIPT

Page 1: TypoScript 2.0

T3CON10 Frankfurt

Robert Lemke

TypoScript 2.0

Samstag, 2. Oktober 2010

Page 2: TypoScript 2.0

Robert Lemkechief architect of TYPO3 Phoenix and FLOW3

co-founder of the TYPO3 Association

34 years old

lives in Lübeck, Germany

1 wife, 1 daughter, 1 espresso machine

likes drumming

Samstag, 2. Oktober 2010

Page 3: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Design GoalsClear Purpose

Consistency

Object-Oriented

Extensible

Samstag, 2. Oktober 2010

Page 4: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

TypoScript 2.0 is an object-oriented view definition language

(don't use it for plain configuration anymore)

Samstag, 2. Oktober 2010

Page 5: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

New Syntax

TypoScript = { TypoScriptLine LineBreak };TypoScriptLine = ( Comment | ConfinementBlock | Declaration | ParseCondition | ObjectDefinition);

ConfinementBlock = ObjectPath "{" LineBreak { TypoScriptLine } "}" ;

Declaration = ( IncludeDeclaration | NamespaceDeclaration );Comment = ( SingleLineComment | BlockComment );ObjectDefinition = ObjectPath ValueOperation;

IncludeDeclaration = "include" ":" "source" "=" DoubleQuote Resource DoubleQuote;NamespaceDeclaration = "namespace" ":" NamespaceIdentifier "=" ObjectName;

SingleLineComment = ( "#" | "//" ) { UnicodeCharacter };BlockComment = "/*" { UnicodeCharacter | LineBreak } "*/";

ObjectPath = [ "." ] ObjectIdentifier { "." ObjectIdentifier } ( [ "." VariableName ] | [ "." ArrayOffset ] );VariableName = "$" Identifier;

ValueOperation = ( ValueAssignment | ValueCopy | ValueReference | ValueUnset | ValueProcessing );ValueAssignment = "=" ( Literal | ObjectType | Constant );ValueCopy = "<" ObjectPath;ValueReference = "=<" ObjectPath;ValueUnset = ">";ValueProcessing = "<<" ArrayOffset "." [ ObjectName "->" ] MethodName "(" { MethodArgument [ "," ] }")";

MethodArgument = Literal | VariableName;

Literal = DoubleQuotedLiteral | SingleQuotedLiteral | Number;DoubleQuotedLiteral = DoubleQuote ( { EscapedUnicodeCharacter } | VariableName ) DoubleQuote;SingleQuotedLiteral = SingleQuote ( { EscapedUnicodeCharacter } | VariableName ) SingleQuote;

ObjectType = ( NamespaceIdentifier "::" Identifier ) | ObjectName;

Constant = (* ... to be defined *);

ParseCondition = (* ... to be defined *);

NamespaceIdentifier = Identifier;ObjectIdentifier = Identifier;MethodName = Identifier;Identifier = Character { CharacterOrDigit };ObjectName = Character { "\" CharacterOrDigit } { CharacterOrDigit };ArrayOffset = Digit;

Number = FloatNumber | IntegerNumber;FloatNumber = IntegerNumber "." Digit { Digit };IntegerNumber = [ "-" ] Digit { Digit };CharacterOrDigit = Character | Digit;UnicodeCharacter = ? All Unicode characters, except line break ?;EscapedUnicodeCharacter = ? All Unicode characters, except line break. Double quote must be escaped when enclosed in double quotes, single quote must be escaped, when enclosed in single quotes, backslash and dollar sign must always be escaped. Escape character is the backslash ?;UpperCaseCharacter = ? Character, but only upper case ?;Character = ? All lower- and uppercase characters between "a" and "z" ?;Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";LineBreak = "\n";DoubleQuote = '"';SingleQuote = "'";

Samstag, 2. Oktober 2010

Page 6: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

CASE

myPage = PagemyPage.title = "Foo"

foo.color = RED

Samstag, 2. Oktober 2010

Page 7: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Literals

foo = 'Single quoted'

bar = "Double quoted"

baz = "I use \" and ' within a quoted literal"

Samstag, 2. Oktober 2010

Page 8: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Comments

foo = Bar // <- here's a comment

# baz = Quux (not active)

/*

page = Page

*/

Samstag, 2. Oktober 2010

Page 9: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Type Safe

thePurpose = 42

theSalary = 41.66

theTruth = FALSE

Samstag, 2. Oktober 2010

Page 10: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Assignments

page = Page

page < coolPage

page.title =< thirdPage.title

page >

Samstag, 2. Oktober 2010

Page 11: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Namespaces

namespace: default = \F3\PlusPlus\TypoScript

page = Page

Samstag, 2. Oktober 2010

Page 12: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Variables

myText = Text

myText.$name = "audience"

myText.headline = "Hello $name!"

Samstag, 2. Oktober 2010

Page 13: TypoScript 2.0

TypoScript 2.0 T3CON10 FrankfurtSamstag, 2. Oktober 2010

Page 14: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

NodesNode Tree instead of Page Tree

Content Types

Samstag, 2. Oktober 2010

Page 15: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

DEMO

Samstag, 2. Oktober 2010

Page 16: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

And stdWrap?

Samstag, 2. Oktober 2010

Page 17: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Processors

myText = Text

myText.text = "Hey you guys really rock and what I always wanted to say "

myText.text << 2.crop(maximumCharacters = 20)

myText.text << 1.wrap('<em>', '</em>')

Samstag, 2. Oktober 2010

Page 18: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Processors

Samstag, 2. Oktober 2010

Page 19: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Customising TypoScriptCreate new Content Types

Tweak or override Fluid Templates

Create new TypoScript Object Types

Samstag, 2. Oktober 2010

Page 20: TypoScript 2.0

TypoScript 2.0 T3CON10 Frankfurt

Questions

Email: [email protected]: http://robertlemke.de/blogTwitter: @t3rob

Slides: http://slideshare.net/rlmp

Samstag, 2. Oktober 2010

Page 21: TypoScript 2.0

Samstag, 2. Oktober 2010