typoscript für anfänger
DESCRIPTION
Session vom TYPO3camp Munich 2008 - Patrick LobacherTRANSCRIPT
TypoScript - von Anfang anInspiring people toshare
TypoScriptvon Anfang an
Spaß an und mit TypoScript
Patrick Lobacher
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)
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
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...)
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
TypoScript - von Anfang anInspiring people toshare
Wo wird TypoScript genau verwendet?
Start einer gerade eben installierten TYPO3-Instanz:
Es fehlen offensichtlich Seiten...
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
TypoScript - von Anfang anInspiring people toshare
Wo wird TypoScript genau verwendet?
Anlegen eines „Templates“ im Backend
TypoScript - von Anfang anInspiring people toshare
Wo wird TypoScript genau verwendet?
Template-Tools
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!“
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
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.
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.
TypoScript - von Anfang anInspiring people toshare
Allgemeine SyntaxEine Standard-Codezeile sieht wie folgt aus :
objektpfad operator wert
Ausnahme: Includes und Conditions
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
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‘;
TypoScript - von Anfang anInspiring people toshare
Assoziativemultidimensionale Variablen
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.']); …
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)
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()';
TypoScript - von Anfang anInspiring people toshare
Verarbeitung von TypoScript
TYPO3-Backend
INHALTE
„Was...“
TYPO3-Frontend
DARSTELLUNG
„Wie...“
TypoScript
TSFE„TypoScript FrontEnd“
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
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*/
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
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>
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)
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
TypoScript - von Anfang anInspiring people toshare
Gibt es eine Übersicht?TypoScriptReference
http://tsref.de
Vorteil: Aktuell
Nachteil: Englisch und teilweise etwas unübersichtlich
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 :-)
TypoScript - von Anfang anInspiring people toshare
Eigenschaften des TLO PAGE
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)
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
TypoScript - von Anfang anInspiring people toshare
Eigenschaften des cObjects TEXT
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> }}
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 }}
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>
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>}
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
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)
TypoScript - von Anfang anInspiring people toshare
Vielen Dank!Fragen???