- TYPO3 Extension Development
- Dmitry Dulepov
- 771字
- 2021-04-25 17:38:16
Frontend API
This part of the API is used in the Frontend. The number of files is relatively small, but the number of functions is very large. We will review only major functions.
TSFE
TSFE (historically stands for "TypoScript Frontend") is the main FE class. It is sometimes called "page" object among developers. This class contains methods that determine page ID, parse TypoScript templates, execute templates, process output and cache it. Also, TSFE is responsible for managing FE user object. TSFE is located in the class tslib_fe
(exercise: see if you can guess the path to the file name).
Normally, extensions do not call TSFE methods but use some TSFE class attributes. We will describe the most important attributes here:
additionalHeaderData
This is an array where FE plugins can add HTML tags that should appear between
<head>
and</head>
on the page. It is a good practice to start withtx_yourextkey_
prefix. Do not add inline<script>
(<script>
tag without src attribute) here!additionalJavaScript
An array where FE plugins may add inline JavaScript, if necessary. It is a good practice to start with
tx_yourextkey_
prefix.config
This is an array. It is the only member with the config key corresponding to the parsed
config
object from the current TypoScript setup. This array contains merged entries fromconfig
andpage.config
.fe_user
An object of the class,
tslib_feUserAuth
, which represents a FE user. Theuser
attribute of this class contains a record from thefe_users
table. If FE user is logged in,$GLOBALS['TSFE']->fe_user->user['uid']
will be set, andt3lib_div::testInt
will returntrue
for it.id
This is the current page ID. It is very often used in FE plugins as
$GLOBALS['TSFE']->id
.lang
This attribute is the current language code (string value). This is not the same as the ISO language code. It is TYPO3 code to be used with language files. The value
default
means English. A full list of codes can be found intypo3/sysext/setup/mod/locallang.xml
as a set oflang_*
entries.page
This is a record from the
pages
table that corresponds to the current page. If the page is loaded in a nondefault language, this record will have that language applied (all fields like title or navigation title will be taken frompages_language_overlay
and applied to this record).pSetup
This is a parsed TypoScript setup for the plugin. This is useful in certain cases. For example, you may want to examine the setup of another plugin. It is a parsed TypoScript array.
register
This is an array of registers (see
LOAD_REGISTER
in TSRef). FE plugins can set registers, and they will be available to other objects on the page (plugins or TypoScript objects from TypoScript setup). The key is register name, value is register value.rootLine
This is an array of records from the
pages
table that represents the path to the current page from the root of the website.sys_language_content
This is a
uid
field value for the record in thesys_language
table. TYPO3 will select content from thett_content
table withsys_language_uid
that matches this value.sys_language_uid
This is a
uid
field value for the record in thesys_language
table. It corresponds toconfig.sys_language_uid
in TypoScript setup.sys_language_mode
See
config.sys_language_mode
in TSRef.
Content Objects
Content objects display information on the page. All content object types are described in TSRef and they are implemented by the class named tslib_cObj
, which is located in typo3/sysext/cms/tslib/class.tslib_content.php
. A quick look at this class reveals familiar names such as TEXT, HTML, USER
, or stdWrap
.
This class is used very often in FE plugins. It has lots of very well-documented methods. We will describe many of them in due course when we have to use them in our real extension.
Plugin API
Last but not the least in its importance is the tslib_pibase
class. This is a base class for the FE plugins. While it is not mandatory to use it, most plugins do because this class provides many helpful methods. We will discuss this class in detail in Chapter 5 of the book. For now, we should know that this class provides the following function groups:
- Link generation
These functions allow plugins to create links with plugin parameters in them.
- Handling of localized labels
These functions help to retrieve translated labels from the language files.
- Frontend editing
These functions help to add FE editing capabilities to plugins (rarely used by plugins).
- Database queries
These functions do specialized database queries. Most of them are equivalents of the
t3lib_DB
functions. - Flexform handling functions
Flexform is a TYPO3 way of having forms inside forms. They are often used for plugin configuration. These functions initialize flexform data and extract information from flexforms.
- 剪映短視頻剪輯零基礎一本通
- 剪映短視頻制作全流程:剪輯、調色、字幕、音效
- VR新未來
- Photoshop CC實戰從入門到精通
- Protel DXP 2004 SP2原理圖與PCB設計(第4版)
- PowerPoint 2019從入門到精通(移動學習版)
- PS App UI設計從零開始學
- Stable Diffusion圖像與視頻生成入門教程
- OpenCV項目開發實戰(原書第2版)
- Oracle BI Publisher 11g: A Practical Guide to Enterprise Reporting
- Cinema 4D R20完全學習手冊
- Procreate數字繪畫實戰教程(全彩微課版)
- 中文版Photoshop CS6經典自學教程(培訓教材版)
- Axure RP8原型設計圖解視頻教程(Web+App)
- 全鏈路UI設計:創意思維+項目實戰+就業指導