I'm writing an extensio in Typo3 9.5 and I can't get the setup.txt or setup.typoscript to load.
I am trying to add a second page type that renders only JSON. For that I gather I need to change the typoscript. Therefore I added this code to my setup.typoscript:
ajax_ajaxjson = PAGE
ajax_ajaxjson {
typeNum = 1
config {
disableAllHeaderCode = 1
additionalHeaders = {
10 {
header = Content-Type: application/json
replace = 1
}
}
xhtml_cleaning = 0
debug = 0
no_cache = 1
admPanel = 0
}
10 < tt_content.list.20.tx_energieportal_ajaxjson
}
(in EXT:\Configuration\TypoScript\setup.txt)
Now when trying to load that page type, I get the following error:
TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
The page is not configured! [type=1][]. This means that there is no TypoScript object of type PAGE with typeNum=1 configured.
I also added a test variable, and when rendering that variable with
<f:cObject typoscriptObjectPath="testvar"/>
I get the error:
No Content Object definition found at TypoScript object path "testvar"
I setup my sys_template.php up like this:
<?php
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'energieportal',
'Configuration/TypoScript',
'Energieportal Frontend'
);
(in EXT:\Configuration\TCA\sys_template.php).
I also tried renaming the setup.txt to setup.typoscript.
Is there anything else I need to do to have my module load the setup.typoscript? I looked at the docs and other modules, but I couldn't find anything for setting up that file.
I used the search function, but the only similar question wasn't really answered. (Link)
If you want to override the TCA of existing tables, you need to put the file into Configuration/TCA/Overrides/.
So, the correct path for your sys_template.php needs to be Configuration/TCA/Overrides/sys_template.php.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile only adds it to the list of static TypoScript files which can be loaded in a TypoScript template. It does not load the TypoScript file automatically.
You will have to include it in a TypoScript template in the TYPO3 backend. You can find the available static templates in the Includes tab under Include static (from extensions).
Alternatively you can include it in a different TypoScript file that is already loaded in the previously mentioned way using #import 'EXT:EXT:energieportal/Configuration/TypoScript/setup.typoscript' or <INCLUDE_TYPOSCRIPT: source="FILE:EXT:energieportal/Configuration/TypoScript/setup.typoscript">
It is also possible to add TypoScript directly from PHP using \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript('My TypoScript'), so you can add the #import or <INCLUDE_TYPOSCRIPT...> line there. You can add this in your extension's ext_localconf.php or Configuration\TCA\Overrides\sys_template.php. It is however usually not recommended as you might not want the TypoScript loaded for all pages and/or sites in a TYPO3 installation.
Related
I have created an extension with sitepackagebuilder.com and the idea is just to write some static html.
I know that when you have a controller you can call the templates by following the convention names. But what if you don't have a controller? What I need, at least for now, is just to install the extension, add the plugin into a page and get some static content in that page.
I can imagine that this is set in a typoscript file but I'm quite noob with all the typoscript thing.
I'm getting this error:
'No Content Object definition found at TypoScript object path "tt_content.list.20.heboorganigram_organigram"'
Until I define that object in my typoscript file. I have tried this.
tt_content.list.20.heboorganigram_organigram = PAGE
tt_content.list.20.heboorganigram_organigram.10 = TEMPLATE //(or FLUIDTEMPLATE same result)
tt_content.list.20.heboorganigram_organigram.10.template = FILE
tt_content.list.20.heboorganigram_organigram.10.template.file = fileadmin/Organigram.html
And then I don't get an error but I also don't get the content from my Organigram.html, this is just trying stuffs, I actually don't know if this is what I need to do.
Before creating new Content Elements you first have to create the Page Template, for that have a look at the sitepackage tutorial https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/FluidTemplates/Index.html
If you already got the page template, have a look at https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html
Provided you already did the steps above, for getting the frontend output you are interested in the step Configure the frontend rendering
So the TypoScript should look something like this:
lib.contentElement {
templateRootPaths.200 = EXT:heboorganigram/Resources/Private/Templates/
}
tt_content {
examples_newcontentelement =< lib.contentElement
examples_newcontentelement {
templateName = NewContentElement
}
}
Then you need to place your Organigram.html file in the Templates Folder in inside the sitepackage.
i can´t change the Login.html template from the EXT:Felogin (10.4.4) in my TYPO3 (10.4.4 latest).
I tried everything.
I changed the path with typoscript in:
Backend (constants and setup)
In my sitepackage (constants and setup)
I even changed the path in the original extension in typo3/sysext/felogin
and nothing worked for me.
Did anybody managed it to changed the template?
In my case in Typo 10.4.6 (own Sitepackage = ***) this Setup works:
SETUP:
plugin.tx_felogin_login {
view {
templateRootPaths.10 = EXT:***/Resources_felogin/Private/Templates/
partialRootPaths.10 = EXT:***/Resources_felogin/Private/Partials/
}
}
Now i can edit Login.html
First it has to be verified which kind of template is used, as since TYPO3 version 10.2 there exist two different plugins and templates:
The old-style template which is using markers in the form ###MARKER###.
This template relies on the old plugin which is still based on piBase
The new fluid-based template is served by the new plugin which is based on extbase.
The switch between these two options is quite uncommon in the feature-settings resided, which can be found here:
The fe_login-setting I found in the very bottom of the modal-window which is opening after having clicked on the button "Feature Toggle":
If the button is activated and therefore shown green fluid-templates are used, else the old marker-template.
It still keeps to mention that the new plugin with fluid-templates inside the extension fe_login is not mentioned in the current official documentation but only in this CHANGELOG
Below I will show the solutions for fluid-templates.
Settings for Fluid-Templates
Enable fluid-templates like explained above if not done yet.
Add the TypoScript shown after the following image if it's missing (you can control it in the Template-Tools for TypoScript:
Take care that you have to switch there between constants and setup to find the correct values if existing.
TypoScript Constants:
plugin {
tx_felogin_login {
view {
# cat=Frontend Login/02_Template/102; type=string; label= Path to template root (FE)
templateRootPath = EXT:felogin/Resources/Private/Templates/
# cat=Frontend Login/02_Template/103; type=string; label= Path to template partials (FE)
partialRootPath = EXT:felogin/Resources/Private/Partials/
# cat=Frontend Login/02_Template/104; type=string; label= Path to template layouts (FE)
layoutRootPath = EXT:felogin/Resources/Private/Layouts/
}
}
}
TypoScript Setup:
plugin.tx_felogin_login {
view {
templateRootPaths {
0 = EXT:felogin/Resources/Private/Templates/
10 = {$plugin.tx_felogin_login.view.templateRootPath}
}
partialRootPaths {
0 = EXT:felogin/Resources/Private/Partials/
10 = {$plugin.tx_felogin_login.view.partialRootPath}
}
layoutRootPaths {
0 = EXT:felogin/Resources/Private/Layouts/
10 = {$plugin.tx_felogin_login.view.layoutRootPath}
}
}
}
tt_content.login < tt_content.felogin_login
Save the record or the files, depending where you added the TypoScript and afterwards in the Template-Tools you can open the constant-editor to add your own values there.
Check the paths and adjust them to your needs. A copy of the fluid-files has naturally to exist in the paths that are entered in the form. They can be adjusted later, but it's advisable to add a headline or some other text for testing if the templates are taken from the right directory.
After clearing the cache the website can be reloaded for controlling if the steps succeeded. If the original templates are shown check all paths and if the templates reside without changes perhaps already in the right directories, just in original form. If nothing or only the headline is shown check if you added a plugin of type login-form and add it on the right page and in the right col if missing.
It has to be expected that in TYPO3 version 10.4.5 or later everything is much easier and some steps here are just not required, like adding the TypoScript-Snippets - they will probably soon reside in the original setup for the extension.
It works here in a 10.4.3 installation:
TS (Setup):
plugin.tx_felogin_login {
view {
templateRootPaths.10 = EXT:sitepackage/Resources/Private/FeLogin/Templates
partialRootPaths.10 = EXT:sitepackage/Resources/Private/FeLogin/Partials
}
}
And place your file in
sitepackage/Resources/Private/FeLogin/Templates/Login/Login.html
The following answer is not correct but includes some links that might be of interest. For a step-by-step-description look for my second answer on this page.
That seems being broken for me in the moment, I tried it out like you without success.
If an individual file-path is entered, the original template is not loaded anymore but the configured file neither.
I found two issues in the bugtracker that seem somewhow related:
Bug #90953: Add missing view path definition for felogin
Task #90566: Provide examples of how to customize / extend the extbase plugin
Its possible that there are still other issues reported related to it, but I never found any on a quick search. First step would be to search here:
Forge issues, category fe_login
second step would be to rermove or change the search filter.
Finally you still can file a new issue, even without searching too much, it doesn't matter much if an issue is reported twice.
Look here. https://review.typo3.org/c/Packages/TYPO3.CMS/+/64080
Add this to your constants and setup override for felogin.
Works totally fine for me in TYPO3 10.4.9
Constants
plugin.tx_felogin_login {
view {
# cat=Frontend Login/02_Template/102; type=string; label= Path to template root (FE)
templateRootPath = EXT:providerExt/Resources/Private/Templates/FeLogin/
# cat=Frontend Login/02_Template/103; type=string; label= Path to template partials (FE)
partialRootPath = EXT:providerExt/Resources/Private/Partials/FeLogin/
# cat=Frontend Login/02_Template/104; type=string; label= Path to template layouts (FE)
layoutRootPath = EXT:providerExt/Resources/Private/Layouts/FeLogin/
}
}
Setup
plugin.tx_felogin_login {
view {
templateRootPaths.10 = {$plugin.tx_felogin_login.view.templateRootPath}
partialRootPaths.10 = {$plugin.tx_felogin_login.view.partialRootPath}
layoutRootPaths.10 = {$plugin.tx_felogin_login.view.layoutRootPath}
}
}
Path to Login.html Override in Template Folder
providerExt/Resources/Private/Templates/FeLogin/Login/Login.html
I have several variables declared in typoscript in this way:
page.10{
variables >
variables {
someId = TEXT
someId.value = 55
:
}
:
}
I need to check some of them in an external PHP file (used for 404 errors). But I can not find the way to access them, I have printed $GLOBALS but it does not get completed printed because it is too long.
Is there a way to get the array containing the page variables?
if you want typoscript values in external PHP you will need to start up the core of TYPO3 as this is the part where typoscript gets interpreted.
I see the following solutions:
do the 404 handling in a TYPO3 page (so you have the TYPO3 core running anyway).
include the TYPO3 core in your PHP and boot it (analog EId-scripts)
just create a special pagetype where you export these variables (e.g. in JSON), so you can call this local page to get them.
In my own extension in TYPO3 7.6, I added typoscript via ext_localconf.php:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(
'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:myextension/Configuration/TypoScript/setup.ts">'
);
The added typoscript is very simple.
But surprisingly this doesn't work:
content < styles.content.get
whereas this works:
content = CONTENT
content {
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
}
It seems to me that copying typoscript-Object generally doesn't work inside files that are included via ExtensionManagementUtility::addTypoScriptSetup.
Is that so? And, if yes: Why is that?
You can copy TS objects in included files.
Things to check:
Does the file FILE:EXT:myextension/Configuration/TypoScript/setup.ts exist?
Is fluid_styled_content or css_styled_content (whatever you use) installed and the TS loaded?
Ordering. Was styles.content.get defined before your TypoScript is included? Put your line from your ext_localconf.php to the setup part of the template record so it is loaded after the static inclusions.
How can I rename a TYPO3 CMS backend field for authors? i.e. the mentioned field for content-elements of csc_styled_content?
In general, overriding label names can by done with Page TSconfig in the backend. The following example modifies the label of the subheader field.
TCEFORM {
tt_content {
subheader.label = My new Label-Name
}
}
There are two way to configure that adjustment in TYPO3.
Type your configuration changes directly to the page settings » resources » TypoScript Configuration » Page TSConfig (see the screenshot below)
as an alternative you can store that configuration directly in the file system - either in your custom extension (e.g. at typo3conf/ext/my_extension/Configuration/TSconfig/labels.t3s) or with a similar name in the global file storage (e.g. fileadmin/templates/configuration/...)
That's basically it to provide custom labels for any database table in the TYPO3 backend. Find more aspects that can be adjusted in the accordant Page TSconfig documentation.
If you want to rename a field of an extension like tx_news you could do it this way.
TCEFORM {
tx_news_domain_model_news {
title.label = Your New Label
}
}
Now there are two ways to get this to work:
Put it in Page TSConfig of the page settings
OR
Load it with your extension from a file (e.g. EXT:my_extension/Configuration/pageTSConfig.typoscript). For that you have to import this script by EXT:my_extension/ext_localconf.php!
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:my_extrension/Configuration/pageTSConfig.typoscript">');