TypoScript Constants
From TYPO3Wiki
|
|||||
| Teams R&D-Committee | This page belongs to Core Team (Members|Contact). see our current activities |
| Current development and maintenance of the TYPO3 core is our mission. | |
This page is a draft designed to be included in the Core manual: TypoScript Syntax and In-depth Study
To insert at the end of Chapter 1.2. Syntax, before "Includes"
Contents |
[edit] Constants
[edit] Declaring and using constants
TypoScript constants are declared quite simply in the "Constants" field of a TypoScript template. Example:
styles.content.imgtext.maxW = 600
To use that constant in a TypoScript template, use the following syntax:
temp.myimage.width = {$styles.content.imgtext.maxW}
Constants declaration can use comments, all operators and conditions, as you would expect since it is TypoScript.
[edit] Preparing for the constant editor
The Web > Template module provides a feature called the Constant Editor. With this editor it is possible to modify TypoScript constants in a user-friendly way. But not all constants will readily appear in the Constant Editor. Only properly declared constants will show up here. Here is an example syntax:
#cat=content,basic/cImage/a_maxw1; type=int+; label= Max Image Width: This indicates that maximum number of pixels (width) a block of images inserted as content is allowed to consume. styles.content.imgtext.maxW = 600
Let's check this syntax in depth:
"cat" is the category of the constant definition. Several categories may be assigned though one is the standard. The category can consist of category, subcategory and a sorting
"type" is the type of the constant and defines of what nature the imput file will be
"label" is a description label for the constant
[edit] Constant Types
Example:
# cat=basic/xxx/010; type=string; label= string: my String t1 = Ich bin ein String # cat=basic/xxx/011; type=int; label= int: (Integer, may be negative) t2 = -99 # cat=basic/xxx/012; type=int+; label= int+: (Integer, only positive) t3 = 88 # cat=basic/xxx/013; type=offset; label= offset: (x and y values) t4 = 88, 55 # cat=basic/xxx/010; type=color; label= color: a color picker t5 = ff0000 # cat=basic/xxx/011; type=wrap; label= wrap: a Wrap t51 = <b>|</b> # cat=basic/xxx/011; type=options[de, en, fr, zh]; label= options[de, en, fr, zh] a drop down option field t7 = de # cat=basic/xxx/010; type=boolean; label= enable: a checkbox t8 = 1 # cat=basic/xxx/010; type=file[png, jpg, gif]; label= file[png, jpg, gif] eine Datei t9 = fileadmin/clear.gif # cat=basic/xxx/010; type=small; label= small a short input field t10 = xyz
Additionally a user defined field exists: "user" and a "comment" field for non-edidable values exist.
[edit] Constant categories
The Constant's main category defines on witch page in the constant editor the constant will appear The following constant categories are pre-defined:
- 'basic': Constants of superior importance for the template-layout. This is dimensions, imagefiles and enabling of various features. The most basic constants, which you would almost always want to configure.
- 'menu': Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype.
- 'content': All constants related to the display of pagecontent elements
- 'page': General configuration like metatags, link targets
- 'advanced': Advanced functions, which are used very seldomly.
- 'all': All constants are put here also!
Custom main categories can be defined for extensions. Example:
- cat=plugin.tx_lot3blog/color/210; type=color; label=Tagcloud Minimum Color
The subcategories define in what section the constant should go. The following standard subcategories exist:
- 'enable': Enable features
- 'dims': Dimensions, widths, heights, pixels
- 'file': Files
- 'typo': Typography
- 'color': Colors
- 'links': Links and targets
- 'language': Language specific constants
Furthermore the following content-element-specific subcategories exist: cheader, cheader_g, ctext, cimage, cbullets, ctable, cuploads, cmultimedia, cmailform, csearch, clogin, csplash, cmenu, cshortcut, clist, cscript, chtml
