[Typo3] template record - constants vs setup - what's the difference

Christopher bedlamhotel at gmail.com
Mon Oct 24 17:27:31 CEST 2005


Hi,

On 24/10/05, Michael Baker <mbaker at pobox.com> wrote:
> What is the difference between the constants section and the setup
> section of a template record?
>
> When do I use one and when the other?
>
> Why are there two separate sections?
>
> Michael.
>
> PS please feel free to point me at some documentation that I have not
> found yet.


The constant editor is mostly a means for you to re-use values in your
TS templates. Imagine, for example, that you're creating multiple
objects in a template that need to use the same colour value or width.
You might do this in a template:

CONSTANTS:

color = #ff9900
width = 300


SETUP

page.headerData {
  5 = HTML
  5 {
    value (
      a {
        color:#{$color};
      }

      #sidebar {
        width:{$width}px;
        border:2px solid #{$color};
      }

      #sidebar h2 {
        width:{$width}px;
      }
    )
  }
}

This is sort of a contrived example, but I think it illustrates the
point; the stuff in the setup part of the template creates or
manipulates front-end rendered content, while the constants field
contains configuration information for TS objects in the setup field.

In addition, there's an extension (which you may need to install)
under the Templates module called the 'Constant Editor'. You can use
comments in the Constants field along with the Constant Editor
extension to provide a basic GUI for changing the values of constants.
This feature is most widely used to provide a relatively simple way to
configure extensions' TS values.

You can find more information about the latter in section 2.5 of the
(slightly dated but not out-of-date) Typoscript Templates manual [1].

-Christopher

[1] http://typo3.org/documentation/document-library/doc_core_tstemplates/



More information about the TYPO3-english mailing list