Typo3 using constants in "Constant" field - typo3

I want to form file path.
In "Constant" field:
const.siteName = site
templates = fileadmin/templates/{$const.siteName}/
When i look in typoscript object browser:
[siteName] = site
[templates] = fileadmin/templates/{$const.siteName}/
Is it possible to achieve this:
[templates] = fileadmin/templates/site/
using const.siteName?
If yes, how?
=========================================================================
EDIT:
What i am tying to do is next:
In my extension configuration
const.siteName = foo
const.templates = fileadmin/templates/($const.siteName)/
const.path.extensions = ($const.templates)/ext/
I include my extension in typoscript template. In my extension setup i include setup for plugin like this:
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:foo/Configuration/TypoScript/Plugin/formhandler.ts">
In Configuration/TypoScript/Plugin/formhandler.ts:
plugin.Tx_Formhandler {
/* snip */
settings.predef.member {
templateFile.value = {$const.path.extensions}formhandler/member/step-1.html // doesn't work
//templateFile.value = fileadmin/templates/foo/ext/formhandler/member/step-1.html // works
}
/* snip */
}

For me, this example works perfect:
Constants:
const.test = foo
const.test2 = {$const.test}/bar
Setup:
page = PAGE
page.10 = TEXT
page.10.value = {$const.test}
page.10.wrap = <p>|</p>
page.20 = TEXT
page.20.value = {$const.test2}
page.20.wrap = <p>|</p>
Output in Browser:
foo
foo/bar
Tested with TYPO3 4.5 and 8.3

Have a look at the TYPO3 NG/ML/Forum:
https://forum.typo3.org/index.php?t=msg&th=212721&goto=740111&#msg_740111
there are a lot of hints how to use constants in typoscript:
you can reuse constants in constants definition, but only up to 10 levels deep.
you can use constants in conditions, but only in setup-part

short : NO
long: you can only use constants in your setup.
what you can do is:
CONSTANTS
const.siteName = site
const.templatePath = fileadmin/templates
SETUP:
myTemplate= {$const.templatePath}/{$const.siteName}

Related

Typo3 Typoscript additionalHeaders header location using variable

I try to redirect a link which is coming, but before part of the link should be replaced.
tmp.getSlug = TEXT
tmp.getSlug.data = getIndpEnv : TYPO3_REQUEST_URL
tmp.getSlug.replacement {
10 {
search = myLinkPart
replace = myNewLinkPart
}
}
config.additionalHeaders.10 {
header = Location: {tmp.getSlug}
}
So from: www.myUrl.de/test/myLinkPart/test2/
To: www.myUrl.de/test/myNewLinkPart/test2/
It must be inside Typoscript because of other conditions.
Does anybody has an idea?
you are mixing different objects in a non functional way.
First you define tmp.getSlug as a typoscript object. Then you try to use it as a data variable.
Additional everything beyond tmp. is not available at rendering time. (it just is available when the typoscript is scanned.)
If you want to use the evaluation of tmp.getSlug you need to assign it to a permanent object and then store it in a register so you can access it afterwards.
Additional you need a flexible object to compose the Location header, which by default just contains a string.
Either a text object where you can use data (which must be evaluated and stored in a register before) or a COA to compose the static and the dynamic string.
This might be a solution:
tmp.getSlug = TEXT
tmp.getSlug.data = getIndpEnv : TYPO3_REQUEST_URL
tmp.getSlug.replacement {
10 {
search = myLinkPart
replace = myNewLinkPart
}
}
config.additionalHeaders.10 {
header.cObject = COA
header.cObject {
10 = TEXT
10.value = Location:
20 < tmp.getSlug
}
}

How to make an extension configurable through extension manager (TYPO3)

I am currently developing my own TYPO3 extension (in v 9.5.11) and I would like to make some settings of my extension customisable. When I go to Admin Tools-->Settings-->Extension Configuration-->Configure Extensions, I can already change those settings.
However in earlier versions of TYPO3 (e.g. v7) it was possible to also make an extension configurable through Admin Tools-->Extensions-->"clicking the settings wheel of the desired extension" (see picture).
Where do I implement said function?
You simply define your desired settings in the file ext_conf_template.txt which needs to be stored in the root level of your extension.
The official TYPO3 documentation contains detailed instructions.
Like Michael said, you need to put all settings into the ext_conf_template.txt
Here is an example of my extension "slug" wich you can also find on Github or in the TYPO3 repository. It contains some special fields and even translations.
# Settings
###########################
# cat=defaults; type=options[10,20,30,40,50,60,70,80,90,100,150,200,300,400,500]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.maxentries
defaultMaxEntries = 20
# cat=defaults; type=options[crdate,tstamp,title,slug,sys_language_uid,is_siteroot,doktype]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.orderby
defaultOrderBy = crdate
# cat=defaults; type=options[DESC,ASC]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.order
defaultOrder = DESC
# cat=defaults; type=boolean; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.recordInfoEnabled
recordInfoEnabled = 1
# cat=tree; type=boolean; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:tree.enabled
treeEnabled = 1
# cat=tree; type=options[1,2,3,4,5,6,7,8,9,10]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:tree.depth
treeDefaultDepth = 3
# cat=tree; type=string; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:tree.root
treeDefaultRoot =
# cat=custom records; type=boolean; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.enabled
recordEnabled = 0
# cat=custom records; type=options[10,20,30,40,50,60,70,80,90,100,150,200,300,400,500]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.maxentries
recordMaxEntries = 10
# cat=custom records; type=options[crdate,title,path_segment,sys_language_uid]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.orderby
recordOrderBy = crdate
# cat=custom records; type=options[DESC,ASC]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.order
recordOrder = DESC
And here is how I use the settigs in any Controller I want:
<?php
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
class ExtensionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
public function __construct() {
$this->backendConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('slug');
}
public function myRandomFunction(){
$variable = $this->backendConfiguration['recordMaxEntries'];
}
}
This is how it looks:

TYPO3 Update to 8.7 Template not working

I try to update an Typo3 Installation from 6.1 to 8.7 LTS but i dont get the templates working.
What i did so far:
Updated the core to 6.2 -> 7.6 -> 8.7
Updated all the Extensions as possible
The old installation used Fluid Pages Engine but this is not available for 8.7. As far as i understand it, fluid is now included in typo3?
Backend is working so far. I can administrate users, Pages and everything i looked at. However, when i call the frontend, i get an Exception:
#1294587217: The page is not configured! [type=0][]. This means that there is no TypoScript object of type PAGE with typeNum=0 configured.
TYPO3\CMS\Core\Error\Http\ServiceUnavailableException thrown in file
...\typo3_src-8.7.10\typo3\sysext\frontend\Classes\Controller\TypoScriptFrontendController.php in line 2487.
I tried the solution from the wikipage and replaced the "setup"-Template information
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/typoscript/domain.ts">
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/typoscript/typoscript.ts">
page.stdWrap.parseFunc.short.i3 = <span style="text-transform:normal;">i3</span>
with
# Default PAGE object:
page = PAGE
# Define output for typeNum=0, the default type.
page.typeNum = 0
page.10 = TEXT
page.10.value = HELLO WORLD!
Then i see "HELLO WORLD!". Now i stuck: what do i have to do to get the "normal" template working?
Thanks in advance
TYPO3 7 and 8 both include the FLUIDTEMPLATE Typoscript object, but EXT:fluidpages is an external extension mantained by the fluidtypo3.org team.
As you wrote:
# Default PAGE object:
page = PAGE
# Define output for typeNum=0, the default type.
page.typeNum = 0
page.10 = TEXT
page.10.value = HELLO WORLD!
You are defining that the PAGE object will contain only that simpe TEXT object.
A "minimum" configuration to use the FLUIDTEMPLATE object would be:
page = PAGE
page.typeNum = 0
page.10 = FLUIDTEMPLATE
page.10{
templateName = Default
layoutRootPaths {
0 = Path/To/Your/Layouts/
}
partialRootPaths {
0 = Path/To/Your/Partials/
}
templateRootPaths {
0 = Path/To/Your/Templates/
}
}
which means that you are using an Default.html template
to use different templates, you should also configure some backend layouts; assuming that you are using the database to store them the previous code could become:
page = PAGE
page.typeNum = 0
page.10 = FLUIDTEMPLATE
page.10{
templateName= TEXT
templateName.stdWrap {
cObject = CASE
cObject {
key.data = levelfield:-2,backend_layout_next_level,slide
key.override.field = backend_layout
default = TEXT
default.value = Default
//these are the IDs of the backend_layout records in DB
1 = TEXT
1.value = Default
2 = TEXT
2.value = Home
//add other values
}
ifEmpty = Error
}
layoutRootPaths {
0 = Path/To/Your/Layouts/
}
partialRootPaths {
0 = Path/To/Your/Partials/
}
templateRootPaths {
0 = Path/To/Your/Templates/
}
}
See also: https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html
If you need further help I could suggest you to join the typo3 Slack channel (subscribe here: https://forger.typo3.com/slack) and join the typo3-cms channel and the fluidtypo3 channel.
I think your typoscript file is not included in ROOT Template.
First of copy all typoscript in the typoscript.ts file and paste in the setup.ts in ROOT Template and after check the frontend. If every thing is fine then definitely your typoscript is not included on ROOT template and if this is not working then some mistake in your typoscript object

Typo3 GP Variables in Form

I created a COA_INT like this:
lib.linguasitoparametrol = COA_INT
lib.linguasitoparametrol {
10 = TEXT
10.stdWrap.data = GP:L
}
I print in fluid like so:
Value = {f:cObject(typoscriptObjectPath: 'lib.linguasitoparametrol')}
Result is: Value = 0 or Value = 1.
Ok it works.
Now i want to write the variable in a input area so i write:
<f:form.textarea name="search[languageUid]" value="{f:cObject(typoscriptObjectPath: 'lib.linguasitoparametrol')}" />
But i obtain in input value <!--INT_SCRIPT.5e0cf67ea790e31ff7adaa744a7a992c-->
Why? how can i solve it?
The <!--INT_SCRIPT.5e0cf67ea790e31ff7adaa744a7a992c-->should only displayed if you do not cache the page witch contain your template.
<!--INT_SCRIPT.5e0cf67ea790e31ff7adaa744a7a992c--> Is an placeholder for you content that is replaced after cache has build.
You dont need for GP:L a COA_INT object: When you have multiple languages you have allready typoscript conditions for these. So your Cache is build for each of these. The Cache for L=1 is allways different than the cache for L=2.
I would recommend to use it without use of COA:
lib.linguasitoparametrol = TEXT
lib.linguasitoparametrol.data = GP:L
Alternative if you use it in an Fluid Template you can pass the information via variables:
page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
template = FILE
template.file = fileadmin/templates/MyTemplate.html
partialRootPath = fileadmin/templates/partial/
variables {
currentLangUid = TEXT
currentLangUid.data = GP:L
}
}
And use it in your Fluid Template by {currentLangUid}, so you dont have to use the cObject Viewhelper.

TYPO3: Special tt_contenttype. Modify content before output

Can I create a "special" type of tt_content, so text is beeing processed in some custom ways before outputtet?
In my case I would like to add ###MY_MARKER### somewhere in header and/or bodytext and have it replaced by the right words for the given page.
eg:
When visiting this page: mypage.com/?marker=test
Header in tt_content: "Welcome to ###MY_MARKER##, enjoy
Output in browser: "Welcome to TEST, enjoy"
I CAN do it by making a custom plugin. Question is more if I can reuse normal tt_contant for the same purpose
Yes, you can easily extend the tt_content by adding your own TCA configuration to the typo3conf/extTables.php file:
t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['columns']['CType']['config']['items']['user_my_type'] = array(
0 => 'My custom content',
1 => 'user_my_type',
2 => 'i/tt_content.gif',
);
$TCA['tt_content']['ctrl']['typeicon_classes']['user_my_type'] = 'mimetypes-x-content-text';
$TCA['tt_content']['ctrl']['typeicons']['user_my_type'] = 'tt_content.gif';
/* In the following either copy, insert and modify configuration from some other
content elemenet (you can find it in the ADMIN TOOLS -> Configuration - $TCA)... */
$TCA['tt_content']['types']['user_my_type']['showitem'] = '';
/* ...or assign it some other configuration so that it's exactly the same
as some other content type and stays the same after some update of TYPO3: */
$TCA['tt_content']['types']['user_my_type']['showitem'] = $TCA['tt_content']['types']['text']['showitem'];
After that, just set in your Typoscript template how the element is supposed to be rendered:
tt_content.user_my_type = COA
tt_content.user_my_type {
10 = TEMPLATE
10 {
template = TEXT
template.field = header
marks {
MY_MARKER = TEXT
MY_MARKER.value = TEST
}
}
20 = TEMPLATE
20 {
template = TEXT
template {
field = bodytext
required = 1
parseFunc = < lib.parseFunc_RTE
}
marks < tt_content.user_my_type.10.marks
}
}
NOTES
The Typoscript rendering is just a simplified example. You might want to add other standard configuration like in other elements, e.g. the one that adds edit icons for frontend display.
The marker in my example can be populated by the value of a GET paramater in the URL as you wanted but this would have nasty security implications. You would certainly need very good validation of that input.