typoscript für anfänger

40
TypoScript - von Anfang an Inspiring people to share TypoScript von Anfang an Spaß an und mit TypoScript Patrick Lobacher

Upload: patrick-lobacher

Post on 19-May-2015

9.368 views

Category:

Technology


1 download

DESCRIPTION

Session vom TYPO3camp Munich 2008 - Patrick Lobacher

TRANSCRIPT

Page 1: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

TypoScriptvon Anfang an

Spaß an und mit TypoScript

Patrick Lobacher

Page 2: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Zitat Kaspar Skårhøj TypoScript was based on the clear whish from me, that TYPO3 had to be flexible enough for any website I could dream up.

(Oktober 2007)

Page 3: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Vorurteile über TypoScriptTypoScript ist kompliziert

TypoScript ist unlogisch

TypoScript brauche ich nicht wirklich

TypoScript ist etwas für Programmierer

TypoScript ist ein notwendiges Übel

Page 4: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Vorurteile über TypoScriptTypoScript ist kompliziert

TypoScript ist unlogisch

TypoScript brauche ich nicht wirklich

TypoScript ist etwas für Programmierer

TypoScript ist ein notwendiges Übel

Stimmt ja gar nicht!!

(naja, zumindest nicht alles...)

Page 5: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Die Wahrheit dagegen istTypoScript ist extrem leistungsfähig

TypoScript ist relativ einfach zu lernen

Für TypoScript werden keinerlei Programmierkenntnisse vorausgesetzt

TypoScript ist genau DER Unterschied zu anderen CMS wie Joomla oder Drupal

TypoScript kann sogar Spaß machen

Page 6: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Wo wird TypoScript genau verwendet?

Start einer gerade eben installierten TYPO3-Instanz:

Es fehlen offensichtlich Seiten...

Page 7: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Wo wird TypoScript genau verwendet?

Nach dem Anlegen der Seiten:

Missverständliche Meldung! Es gibt TypoScript-Templates und HTML-Templates

Page 8: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Wo wird TypoScript genau verwendet?

Anlegen eines „Templates“ im Backend

Page 9: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Wo wird TypoScript genau verwendet?

Template-Tools

Page 10: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Wo wird TypoScript genau verwendet?

Inhalt des Feldes „Setup“:# Default PAGE object:page = PAGEpage.10 = TEXTpage.10.value = HELLO WORLD!

Ausgabe der Seite ist „HELLO WORLD!“

Page 11: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

TypoScript-TemplatesEin TypoScript-Template kann einer Seite zugeordnet werden und wird nach unten vererbt (kaskadieren)

Eine weiteres TypoScript-Template kann ein anderes überschreiben

Extensions können auch eigene TypoScript-Templates einbringen

Page 12: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Die Definition von TypoScriptTypoScript bildet mithilfe von Plaintext und einer gegebenen Syntax hierarchische Informationen in ein multidimensionales assoziative PHP-Array ab.

Page 13: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Die Definition von TypoScriptTypoScript bildet mithilfe von Plaintext und einer gegebenen Syntax hierarchische Informationen in ein multidimensionales assoziatives PHP-Array ab.

Page 14: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Allgemeine SyntaxEine Standard-Codezeile sieht wie folgt aus :

objektpfad operator wert

Ausnahme: Includes und Conditions

Page 15: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Allgemeine SyntaxIm Objektpfad werden die einzelnen Bestandteile (sofern vorhanden) mittels Punkt getrennt. Dies stellt die Hierachie dar.

Beispiele:objekt1 = wert1objekt2.eigenschaft2 = wert2objekt3.eigenschaft3.eigenschaft3 = wert3objekt4.eigenschaft4.objekt4 = wert4

Page 16: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Assoziatives Array?INHALT = CONTENTINHALT { table = tt_content select.orderBy = sorting select.where = colPos = 1 select.languageField = sys_language_uid}

INHALT = CONTENTINHALT.table = tt_contentINHALT.select.orderBy = sortingINHALT.select.where = colPos = 1INHALT.select.languageField = sys_language_uid

$GLOBALS['TSFE'][‘INHALT‘] = ‘CONTENT‘;$GLOBALS['TSFE'][‘INHALT.‘][‘table‘] = tt_content;$GLOBALS['TSFE'][‘INHALT.‘][‘select.‘][‘orderBy‘] = ‘sorting‘;$GLOBALS['TSFE'][‘INHALT.‘][‘select.‘][‘where‘] = ‘colPos = 1‘;$GLOBALS['TSFE'][‘INHALT.‘][‘select.‘][‘where‘][‘languageField‘] = ‘sys_language_uid‘;

Page 17: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Assoziativemultidimensionale Variablen

Page 18: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Was macht TYPO3 damit?$GLOBALS['TSFE'][‘INHALT‘] = ‘CONTENT‘;$GLOBALS['TSFE'][‘INHALT.‘][‘table‘] = tt_content;$GLOBALS['TSFE'][‘INHALT.‘][‘select.‘][‘orderBy‘] = ‘sorting‘;$GLOBALS['TSFE'][‘INHALT.‘][‘select.‘][‘where‘] = ‘colPos = 1‘;$GLOBALS['TSFE'][‘INHALT.‘][‘select.‘][‘where‘][‘languageField‘] = ‘sys_language_uid‘;

function CONTENT($conf) { $originalRec = $GLOBALS['TSFE']->currentRecord; if ($conf['table']=='pages' || substr($conf['table'],0,3)=='tt_' || substr($conf['table'],0,3)=='fe_' || substr($conf['table'],0,3)=='tx_' || substr($conf['table'],0,4)=='ttx_' || substr($conf['table'],0,5)=='user_') { do { $res = $this->exec_getQuery($conf['table'],$conf['select.']); …

Page 19: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

KonsequenzenTypoScript ist keine Sprache, es dient der Konfiguration

Unbekannte TypoScript-Teile werden schlicht ignoriert => keine Fehlermeldung

Durch TypoScript wird PHP-Code ausgeführt

Der zuletzt gesetzte Wert ist gültig (manchmal schwierig herauszufinden)

Page 20: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Interne TypoScript-Speicherung

Die Variable $GLOBALS[‘TSFE‘] enthält die komplette TypoScript-Konfiguration

Ausgabe durchprint_r($GLOBALS[‘TSFE‘] );

Beschreiben ist ebenfalls möglich, z.B. :$GLOBALS['TSFE']->pSetup['bodyTagAdd'] = 'onload="load()" onunload="GUnload()';

Page 21: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Verarbeitung von TypoScript

TYPO3-Backend

INHALTE

„Was...“

TYPO3-Frontend

DARSTELLUNG

„Wie...“

TypoScript

TSFE„TypoScript FrontEnd“

Page 22: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Syntax - Operatorenobjektpfad operator wert

= Zuweisen [page = PAGE]

:= Modifikation [page.10 := appendString(„Test“)]

> Löschen [page.10 >]

< Kopieren [ACT < .NO]

=< Referenz

Page 23: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Syntax - KommentareEs gibt mehrere Möglichkeiten, Kommentare in den Code zu bringen

# Das ist ein Kommentar// Das ist auch ein Kommentar/ Es ist sogar nur ein Slash notwenig/* Und mehrzeilige Kommentaresind auch möglich*/

Page 24: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Syntax - AusklammernVerkürzt den Code, erhöht die Übersichtlichkeit

Lediglich andere Schreibweise

INHALT = CONTENTINHALT { table = tt_content select.orderBy = sorting select.where = colPos = 1 select.languageField = sys_language_uid}

INHALT = CONTENTINHALT.table = tt_contentINHALT.select.orderBy = sortingINHALT.select.where = colPos = 1INHALT.select.languageField = sys_language_uid

Page 25: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Syntax - Wraps |Ein Wrap legt sich wie eine Hülle um einen Wert

page.10 = TEXTpage.10.value = TYPO3camppage.10.wrap = <h3>|</h3># Resultat ist nun# <h3>TYPO3camp</h3>

Page 26: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Top Level Objekte (TLO)TLOs sind vordefiniert und werden von TypoScript zur Verfügung gestellt

TLO übernehmen die Konfiguration

Die bekanntesten TLOs sind:

CONFIG (Konfiguration des TYPO3-Systems)

PAGE (Konfiguration und Darstellung einer Seite)

Page 27: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

TLO - PAGEInhalt des Feldes „Setup“:# Default PAGE object:page = PAGEpage.10 = TEXTpage.10.value = HELLO WORLD!

Die möglichen Eigenschaften des TLO PAGE müssen nachgesehen werden

Page 28: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Gibt es eine Übersicht?TypoScriptReference

http://tsref.de

Vorteil: Aktuell

Nachteil: Englisch und teilweise etwas unübersichtlich

Page 29: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Gibt es eine Übersicht?TypoScriptKurz&Gut

Vorteil: Deutsch,Übersichtlich, enthält TS derwichtigsten Extensions

Nachteil: Naturgemäß weniger aktuell

ACHTUNG!Unverschämte Eigenwerbung :-)

Page 30: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Eigenschaften des TLO PAGE

Page 31: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

cObject (cObj / Content Objekte)Bringen die Inhalte ins System

Die bekanntesten cObjects sind:

CARRAY (Content-Array, 1,2,3,4 bei PAGE-TLO)CONTENT (liest Inhalte aus der Datenbank)HTML / TEXT (Texte)FORM (Formulare)IMAGE / IMG_RESOURCE (Bilder)TEMPLATE (HTML-Templates)

Page 32: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

cObject - TEXTInhalt des Feldes „Setup“:# Default PAGE object:page = PAGEpage.10 = TEXTpage.10.value = HELLO WORLD!

Die möglichen Eigenschaften des cObject TEXT müssen nachgesehen werden

Page 33: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Eigenschaften des cObjects TEXT

Page 34: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Beispiel: Inhalte ausgebenpage = PAGEpage { typenum = 0 10 = CONTENT 10 { table = tt_content select.orderBy = sorting select.where = colPos = 0 select.languageField = sys_language_uid wrap = <div id=“content>|</div> }}

Page 35: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Beispiel: Marker füllenpage = PAGEpage { typenum = 0 meta.author = Patrick Lobacher stylesheet = fileadmin/typo3camp.css 10 = TEMPLATE 10.template = FILE 10.template.file = fileadmin/typo3camp.html 10.workOnSubpart = DOCUMENT 10.marks { MENU < lib.mainmenu }}

Page 36: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Beispiel: Marker füllen - Template<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" ><head> <title>TYPO3camp</title></head><body><!-- ###DOCUMENT### begin --><div id="MENU"> ###MAINMENU###</div><!-- ###DOCUMENT### end --></body></html>

Page 37: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Beispiel: Menülib.mainmenu = HMENUlib.mainmenu { 1 = TMENU 1.wrap = <ul class=“ebene1“>|</ul> 1.NO.allWrap = <li>|</li> 1.ACT = 1 1.ACT.wrapItemAndSub = <li>|</li> 2 < .1 2.wrap = <ul class=“ebene2“>|</ul> 3 < .2 3.wrap = <ul class=“ebene3“>|</ul>}

Page 38: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Beispiel: Menü -Ausgabe<ul class=“ebene1“> <li>Menüpunkt 1</li> <li>Menüpunkt 2 <ul class=“ebene2“> <li>Menüpunkt 2-1</li> <li>Menüpunkt 2-2</li> </ul> <li>Menüpunkt 3</li></ul>

Menüpunkt 1Menüpunkt 2 Menüpunkt 2-1 Menüpunkt 2-2Menüpunkt 3

Page 39: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Weitere Informationen:TypoScript Reference TSrefhttp://www.tsref.de

TypoScript in 45 Minuten (DocTeam)http://wiki.typo3.org/index.php/De:TSref/45MinutesTypoScript

Übersetzung der TSrefhttp://wiki.typo3.org/De:TSref

TypoScript Videotraining (video2brain)

Page 40: TypoScript für Anfänger

TypoScript - von Anfang anInspiring people toshare

Vielen Dank!Fragen???