This document summarizes the standard folder structure and naming conventions for TYPO3 extensions. It outlines where common files like classes, configuration, documentation, and resources should be located. It also provides guidance on naming conventions for classes, methods, and variables, and describes common Extension APIs, repository functions, and view helpers for building TYPO3 extensions.
This document summarizes the standard folder structure and naming conventions for TYPO3 extensions. It outlines where common files like classes, configuration, documentation, and resources should be located. It also provides guidance on naming conventions for classes, methods, and variables, and describes common Extension APIs, repository functions, and view helpers for building TYPO3 extensions.
This document summarizes the standard folder structure and naming conventions for TYPO3 extensions. It outlines where common files like classes, configuration, documentation, and resources should be located. It also provides guidance on naming conventions for classes, methods, and variables, and describes common Extension APIs, repository functions, and view helpers for building TYPO3 extensions.
This document summarizes the standard folder structure and naming conventions for TYPO3 extensions. It outlines where common files like classes, configuration, documentation, and resources should be located. It also provides guidance on naming conventions for classes, methods, and variables, and describes common Extension APIs, repository functions, and view helpers for building TYPO3 extensions.
Folder structure inside extension dir typo3conf/ext/[extension_key]/
Classes/ All PHP classes reside here
Classes/Controller/ Controller classes Classes/Controller/[DomainObjectName]Controller.php Controller of model [DomainObjectName] (rec.) Classes/Domain/ Domain specifc classe Classes/Domain/Model/ Model classes Classes/Domain/Model/[DomainObjectName].php Specifc model class for [DomainObjectName] Classes/Domain/Repository/ Repository classes Classes/Domain/Repository/ [DomainObjectName]Repository.php Repository of model [DomainObjectName] Classes/Domain/Validator/ Validator classes Classes/Domain/Validator/ [DomainObjectName]Validator.php Validator of model [DomainObjectName] Classes/ViewHelpers/ Individual fuid view helpers reside here Classes/ViewHelpers/[VHName]ViewHelper.php View helper with name VHName Conguration/ All confguration (structure is a suggestion) Conguration/Tca.php (or TableConguration.php) Table confguration array (TCA), own dir TCA/ if many Conguration/FlexForms/ Flexforms used for backend forms Conguration/TypoScript/ TypoScript constants and setup (e.g. setup.txt) Documentation/ All documentation reside here Documentation/Manual/ Extension manual, subfolder [format]/[lang]/ Resources/ All resources reside here Resources/Private/ Private resources Resources/Private/Backend/ Resources used by backend modules Resources/Private/Backend/Layouts/ Layout fles for backend modules Resources/Private/Backend/Templates/ Template fles for backend modules Resources/Private/Backend/Templates/ [ControllerName]/ All templates of a specifc controller (BE) Resources/Private/Backend/Templates/ [ControllerName]/[action].[format] Template of [action] from [Controller] (BE) Resources/Private/Language/ Language fles for l10n Resources/Private/Language/locallang.xml Main language fle - use key w. translate viewhelper Resources/Private/Layouts/ Layout fles for frontend plugins Resources/Private/Partials/ Partials fles for frontend plugins Resources/Private/Templates/ Template fles for frontend plugins Resources/Private/Templates/[Controller]/ All templates of a specifc model (FE) Resources/Private/Templates/[Controller]/[action]. [format] Template of [action] from [Controller] (FE) Resources/Public/ Additional resources Tests/ All tests reside here Tests/units/ Unit tests Naming Conventions Classes UpperCamelCase Methods & Variables lowerCamelCase General class naming Tx_[ExtensionName]_[Path].php - [ExtensionName] is extension_key without _ and in UpperCamelCase - [Path] is inside Classes directory of Extension, change / with _ e.g.: Tx_BlogExample_Domain_Model_Post or Tx_Extbase_MVC_Controller_ActionController Interfaces Class name ends in Interface, e.g. Tx_Extbase_MVC_RequestInterface Abstact classes beginning of last class name part is Abstract e.g. Tx_Extbase_MVC_Controller_AbstractController Domain model entity: ... extends Tx_Extbase_DomainObject_AbstractEntity Domain model value object: ... extends Tx_Extbase_DomainObject_AbstractValueObject Extension-API Frontend Plugins ext_localconf.php Tx_Extbase_Utility_Extension::congurePlugin( $_EXTKEY, $pluginName, // Pi1 $controllerActionCombinations, // array([Controller] => action,...) $uncachedActions // array([Controller] => action,...) ); ext_tables.php Tx_Extbase_Utility_Extension::registerPlugin( $_EXTKEY, $pluginName, $backendTitle ); Backend Module ext_tables.php Tx_Extbase_Utility_Extension::registerModule( $_EXTKEY, $main, // main module, e.g. web $sub, // sub module, e.g. tx_simpleblog_m1 $position, // e.g. after or before $controllerActionCombinations, // array([Controller] => action,...) $conf // conguration array like access, icon, labels ); TypoScript plugin.tx_[lowercasedextensionname] & module.tx_[lowercasedextensionname] & cong.extbase settings Access in controller: $this->settings Access in Fluid: {settings} persistence enableAutomaticCacheClearing storagePid classes.[fullClassName] cache clearing at edit/insert operations PID list where records are read from see next persistence.classes. [fullClassName] newRecordStoragePid mapping.tableName. mapping.columns. PID where new records will be stored Which table is mapped Which column in table is mapped persistence.classes { Tx_Extbase_Domain_Model_FrontendUser { mapping { tableName = fe_users columns { usergroup.foreignClass = Tx_Extbase_Domain_Model_FrontendUserGroup lockToDomain.mapOnProperty = lockToDomain view templateRootPath partialRootPath layoutRootPath Template path Partial path Layout path _LOCAL_LANG [ISOlang].key [default].key Localization (key corresponds to the key in fle: Resources/Private/Language/locallang.xml) Custom queries (use in own method inside repository) $query = $this->createQuery(); Initializes a query $query->matching(...CONSTRAINTS...) Query methods. Inside () use constraining methods below CONSTRAINTS Chaining is possible: $query->matching()-> setLimit()->execute(); e.g. $query-> equals(product.category.title, foo) $query->logicalAnd($constraint1, $constraint2); $query->logicalOr($constraint1, $constraint2); $query->logicalNot($constraint); $query->withUid($uid); $query->equals($propertyName, $operand, $caseSensitive); $query->in($propertyName, $operand); $query->contains($propertyName, $operand); $query->like($propertyName, $operand); $query->lessThan($propertyName, $operand); $query->lessThanOrEqual($propertyName, $operand); $query->greaterThan($propertyName, $operand); $query->greaterThanOrEqual($propertyName, $operand); $query->setOrderings( array(property => ORDER)); Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING $query->setLimit((integer)$limit); Result set limit $result = $query->execute() Query and return result ActionController API (Tx_Extbase_MVC_Controller_ActionController) $actionMethodName Name of current action $view current view (of type Tx_Extbase_MVC_View_ViewInterface) $settings Domain specifc settings from TypoScript $request Request object (of type Tx_Extbase_MVC_RequestInterface) $response Response object (of type Tx_Extbase_MVC_ResponseInterface) initializeAction() Initialize method for all actions initialize[ActionName]Action() Initialize method for specifc action [ActionName] [actionName]Action() Specifc method for action [actionName] forward($actionName, $controllerName, $extensionName, array $arguments) Internal redirect of request to another controller redirect($actionName, $controllerName, $extensionName, array $arguments, $pa- geUid, $delay = 0, $statusCode = 303) External HTTP redirect to another controller redirectToURI($uri, $delay=0, $statusCode=303) Redirect to URI throwStatus($statusCode, $statusMessage, $content) Send HTTP status code errorAction() Called at arguments validation error. PHPDoc annotations @param [Type] $var Action: Parameter. $var validates to [Type] @dontvalidate $var Action: No validation for $var (needed for new und edit actions) @var [Type] Model: Type of var in Domain Model - either simple type, class or ObjectStorage: Tx_Extbase_Persistence_ObjectStorage<Tx_[ExtensionName]_Domain_Model_[Model]> delivers methods: attach(), attachAll(), detach(), detachAll(), contains() @validate [$var] [Validator] Model & Action: Validation for $var. In model without $var. @lazy Lazy loading in domain model @cascasde remove Delete child if parent is removed @dontverifyrequesthash Disable request hash checking @return [Type] Return value is of type [Type] Repository API (Tx_Extbase_Persistence_Repository) In controller (dont use new to instanciate a repository!): $[domainModelName]Repository = t3lib_div::makeInstance(Tx_[ExtensionName]_Domain_Repository_[DomainModelName]Repository); add($object) Add object to repository remove($object) Remove object from repository replace($existingObject, $newObject) Replaces an existing object with a new one update($object) Update stored object with $object ndAll() Find all objects of given type countAll() Returns the total number objects of this repository removeAll() Removes all objects of this repository countBy[PropertyName]($propertyValue) Returns the number objects with $propertyName == $propertyValue ndByUid($uid) Finds an object matching the given identifer ndBy[PropertyName]($propertyValue) Find all objects with $propertyName == $propertyValue ndOneBy[PropertyName]($propertyValue) Same as above, just fnd one (the frst found) object Validator API - Validator used as [Validator] in @validate annotation Alphanumeric, DateTime, EmailAddress, Float, Integer, NotEmpty, NumberRange, String, StringLength, Text Possible validators, some have additional params. See typo3/sysext/extbase/Classes/Validation/Validator/ Conjunction TRUE if all child validators are true Disjunction TRUE if at least one child validator are true Extbase Cheat Sheet v 1.00 / 13.04.2010 Patrick Lobacher, Jochen Rau, Sebastian Kurfrst SVN: svn checkout https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/extbase/trunk/ extbase Forge: http://forge.typo3.org/projects/show/typo3v4-mvc Issue-Tracker: http://forge.typo3.org/projects/typo3v4-mvc/issues creativecommons.org/licenses/by-sa/3.0 Addressing the view in action (controller class) $this->view->assign([name], $object) Makes $object available as {name} in fuid $this->view->render() Forces rendering of template (default is at script end) Templates, Layouts, Partials (in directory Resources/Private/...) Template (Templates/[Controller]/ [action].html) <f:layout name=default /> <f:section name=content> <f:render partial=partName arguments=... /> </f:section> Layout (Layouts/default.html) <f:render section=content /> Partial (Partials/partName.html) ... Object accessor syntax {name.property} Object accessor: Result of getProperty() in model [name] {name.key} Associative array: Element in array [name] with [key] {name.number} Numeric array: Element in array [name] at position [number] ViewHelper syntax {namespace f=Tx_Fluid_ViewHelpers} Declares the abbreviation f as namespace for Tx_Fluid_ViewHelpers (this is default). You can add own namespaces. <f:vhname PARAMS> </f:vhname> ViewHelper with the name [vhname]. Corresponding class is found at: typo3/sysext/uid/Classes/ViewHelpers/VhnameViewHelper.php PARAMS Arguments will be listed like: {key1:value1,key2:value2} e.g. each={0:1,1:2,...} or values={0:odd,1:even,...} or arguments={name:object} Inline syntax: <f:vhname ... /> could be written as {f:vhname(...)} and <f:format.nl2br><f:format.crop maxCharacters=20>{some.value}</f:format.crop></f:format.nl2br> could be written as {some.value -> f.format.crop(maxCharacters:20) -> f:format.nl2br()} Boolean expressions - like: condition=XXX operator YYY XXX,YYY is of type number, object accessor, array or ViewHelper inline syntax operator is one of: == != % >= > <= < TagBasedViewHelper (general arguments for tag based viewhelper) used with viewhelper: form (and all sub viewhelper), image, link, renderFlashMessages additionalAttributes Associative array of additional tag-attributes style Individual CSS style class CSS classes for this tag title Tooltip text for this element dir Sets dir attribute - ltr or rtl accesskey Defnes access key id Unique id tabindex Tab order for this element lang Language of this element (RFC 1766) onclick JavaScript for onclick event alias ViewHelper - defne alias of variables map Mapping of alias - array e.g {x:object1,y:object1.property1} base ViewHelper - generates base tag cObject ViewHelper - display TypoScript object typoScriptObjectPath TypoScript object path which should be diplay data Data which is used for the rendering - same as <f:cObject>data</f:cObject> currentValueKey Key which sets the stdWrap property current count viewhelper - counts elements cycle viewhelper - iterates through given values values Array of values which is used for iteration as Name of iteration variable debug ViewHelper - wrapper for TYPO3 debug function title Title for debug output for ViewHelper - foreach function each Array of values or objects which is used for iteration key Key of iteration variable as Name of iteration variable reverse If TRUE, direction will be reversed form ViewHelper - form generation action Form action (default is current url) name Name of form arguments Additonal arguments pluginName Plugin called (default is current plugin) controller Controller which should be called pageUid UID of target page enctype MIME type for transmition pageType Type of target page (default is 0) extensionName Extension which should be called (default is current extension) object Object bound to the form - can be adressed through property method Transfer method (default is post) onreset, onsubmit JavaScript handler GENERAL ATTRIBUTES FOR ELEMENTS name Name of element value Value of element property Property of object which is bound through form disabled Displays the element disabled form.checkbox - displays a checkbox checked If TRUE, the checkbox is checked form.errors - displays the form errors for The errors of the given element will be shown as Name of error variable form.hidden - displays a hidden feld form.password - displays a password input feld maxlength Maximum length of feld size Length of input feld readonly Readonly attribute of feld form.radio - displays a radio button checked If TRUE, the checkbox is checked form.select - displays a selector box options Associative array or object used for options multiple Display a multi-select box optionLabelField Values for label feld are flled from property size Length of selector box optionValueField Values for value feld are flled from property form.submit - displays a submit button form.textarea - displays a text area rows Number of rows cols Number of cols form.textbox - displays an input feld maxlength Maximum length of feld size Length of input feld readonly Readonly attribute of feld form.upload - displays an upload feld format ViewHelper - formats in different ways format.crop - crops text append String, which is append at crop position respectWordBoundaries Crops only at word boundaries maxCharacters Max. characters which are displayed format.currency - displays currency conversions currencySign The currency sign (like $, , ...) thousandsSeparator Character for thousands sep. decimalSeparator Character for decimal separation format.date - displays dates format Format in date() syntax. format.html - renders strings with TYPO3 parseFunc parseFuncTSPath Path to own parseFunc. Default is lib.parseFunc_RTE format.nl2br - wrapper for PHP function nl2br format.number - formats numbers decimals Numbers after comma. Default is 2 thousandsSeparator Character for thousands sep. decimalSeparator Character for decimal separation format.padding - wrapper for PHP function str_pad() padLength Length of outputted string padString String which is used for flling up format.printf - wrapper for PHP function printf() arguments Arguments for printf as array groupedFor ViewHelper - grouping of results as Name of iteration variable groupBy Group by this property each Array or object which is used for iteration groupKey Name of variable which stores the grouping if/then/else ViewHelper - if-then-else (w/o then if there is no else) condition Condition for the if part, right after this follows the then & else viewhelper Shorthand-Syntax: {f:if(condition: {rank} > 100, then: rank is > 100, else: rank is <= 100)} image ViewHelper - displays an image ismap, longdesc, maxHeight, maxWidth, minHeight, minWidth, src, usemap, height, width link ViewHelper - generates links link.action / uri.action - generates extbase action links action Target action noCashHash No cHash parameter additionalParams Additional parameters pageType Page type (default 0) arguments Arguments pageUid Target page UID (default current) controller Target Controller pluginName Target Plugin extensionName Target Extension section Anchor linkAccessRestrictedPages Show even access restricted pages target Target parameter noCache Deactivate cache for target page link.email additionalParams Additional parameters email Email address link.external additionalParams Additional parameters target Target parameter linkAccessRestrictedPages Show even access restricted pages uri Target URL link.page noCache Deactivate cache for target page section Anchor noCashHash No cHash parameter target Target parameter pageType Page type (default 0) uri Target URL pageUid Target page UID (default current) renderFlashMessages ViewHelper - $this->fashMessages->add() class Adds class to fash message list element translate ViewHelper - (from Resources/Private/Language/locallang.xml) htmlEscape If TRUE, the output will be escaped key Key in locallang fle API: Write own ViewHelper with name [vhname] Put fle [Vhname]ViewHelper.php in Classes/ViewHelpers/ with the following class defnition: class Tx_[ExtKey]_ViewHelpers_[Vhname]ViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper $arguments Associative array of arguments of viewhelper. Accessible within render() $templateVariableContainer Contains all variables which are accessible in the template. Change with add() & remove() $controllerContext Context of controller - serves as API for the controller. Supports the following properties: request, response, arguments, argumentsMappingResults, uriBuilder, fashMessageContainer $viewHelperVariableContainer Container for exchanging data between viewhelpers. Add with add() & read with get() initializeArguments() Register arguments with $this->registerArgument($name, $type, $description, $required, $defaultValue) initialize() Code before rendering of viewhelper render() Render method which is responsible for output of viewhelper. Its required. renderChildren() Called within render() will return all rendered content from child elements class Tx_[ExtKey]_ViewHelpers_[Vhname]ViewHelper extends Tx_Fluid_Core_ViewHelper_TagBasedViewHelper $tagname Name of Tag which will be gererated by the viewhelper $tag Instance TagBuilder (API see below) __construct() Constructor. You should call parent::construct(). initialize() Code before rendering of viewhelper. You should call parent::initialize() registerTagAttribute($name, $type, $description, $required) Registers a viewhelper argument which is directly used as tag attribute. Should be called within initializeArguments() registerUniversalTagAttributes() Registers all universal tag attributes like class, dir, id, lang, style, title, accesskey, tabindex Relevant API of TagBuilder setContent($tagContent), getContent(), forceClosingTag($forceClosingTag), addAttribute($attributeName, $attributeValue, $escapeSpecialCharacters = TRUE), addAttributes(array $attributes, $escapeSpecialCha- racters = TRUE), removeAttribute($attributeName), reset(), render() Fluid Cheat Sheet SVN: svn checkout https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/uid/trunk/ uid Forge: http://forge.typo3.org/projects/show/package-uid Issue-Tracker: http://forge.typo3.org/projects/package-uid/issues creativecommons.org/licenses/by-sa/3.0 v 1.00 / 13.04.2010 Patrick Lobacher, Jochen Rau, Sebastian Kurfrst