.. include:: /Includes.rst.txt .. index:: TypoScript; Register usage .. _using-setting-register: ======== Register ======== It is possible to store variable values into a memory stack which is called "register". The cObjects :ref:`LOAD_REGISTER ` and :ref:`RESTORE_REGISTER ` provide this storage functionality. Some TYPO3 cObjects use internal registers. Esp. the menus are built by registers (e.g. count_HMENU, count_HMENU_MENUOBJ, count_menuItems). .. _using-setting-register-defining-registers: Defining registers ================== Registers in TypoScript can be seen as stack array variables in programming languages. Each register can store a complex TypoScript block. Use :ref:`LOAD_REGISTER ` to put a variable to the stack, use :ref:`RESTORE_REGISTER ` to pull a variable from the stack and curly braces around a variable name to read the current value of the variable. You need a :ref:`data ` or a :ref:`dataWrap ` cObject. The registers cannot be read on other places than inside of these cObjects. .. _using-setting-register-example: Example ======= .. literalinclude:: _example2.typoscript :caption: EXT:my_sitepackage/Configuration/Sets/Main/setup.typoscript This example shows a part of a TypoScript which builds a 2 column menu based on a spacer page. A class is added to the ul tag depending on the value of the register variable `ulClass`. The first pages will have the class `col-left` and the pages following the spacer page will get the class `col-right`. :typoscript:`{register:variablename}` returns the "current" value of the variable `variablename`. A register stack can be like any TypoScript setup. .. literalinclude:: _register.typoscript :caption: EXT:my_sitepackage/Configuration/Sets/Main/setup.typoscript The "current" value is just an internal variable that can be used by functions to pass a single value on to another function later in the TypoScript processing. It is like "load accumulator" in the good old C64 days. Basically you can use a "register" as you like. The TSref will tell if functions are setting this value before calling some other object so that you know if it holds any special information.