-->

Searching for TYPO3 Extension: Global Variables

2019-07-11 17:18发布

问题:

I am searching for a TYPO3 extension that lets me define variables and use them everywhere in the TYPO3 backend (something like %CEO_NAME%).

The customer wants to define names and addresses (for their CEO for example) centrally, so that when another person gets the job they can just change it once and it gets replaced in every RTE, page title, keyword, etc.

Is there some extension that would allow me to do that easily or is there an easy way this could be achieved with TS?

If at all possible I would like to avoid writing an own extension for this as the budget is somewhat tight on that project.

回答1:

There are some possibilities with typoscript. Which means no editor can maintain the replacements.

One solution: at last in the rendering process you replace any occurence:

page = PAGE
page {
    :
    do the rendering of the page
    :
    // now replace any occurence:
    stdWrap.replacement {
        1.search = __CEO__
        1.replace = John Doe

        2.search = __COMPANY__
        2.replace = ACME
    }
}

Be careful to select an unique key as the replacement is done everywhere (in HTML tags, in (inline) javascript/CSS, ...).

Advantage: this replacement can use regular expressions.


Next solutions:
Enhance the parsefunc, which is used for textarea fields.

tt_content.text.20 {  <- example
    parseFunc {
        constants {
            // replaces '###CEO###' with 'John Doe'
            CEO = John Doe
        }
        short {
            __CEO__ = John Doe
        }
    }
}

This will replace the markers only in the fields this parseFunc is active.