How do I override the rendering of a Content Element in fluid_styled_content? - typo3

In TYPO3 8.7 I am trying to override the file Textpic.html from fluid_styled_content so that I can use my own rendering for the textpic content element.
As long as I modify the original file inside the extension itself, this is working fine.
However, I want to create my own copy of this file and use that copy. This is not working - TYPO3 does not use my own version of the file.
Here is what I did:
In the Setup field of my TypoScript template I added:
lib.contentElement.templateRootPaths.100 = /fileadmin/template/Templates/
Then I copied Textpic.html from fluid_styled_content/Resources/Private/Templates into my folder /fileadmin/template/Templates so that it becomes /fileadmin/template/Templates/Textpic.html.
Any hints, what I might be missing?

You can do this by setting constants. For example
styles.templates {
templateRootPath = EXT:siteconfig/Resources/Private/Extensions/fluid_styled_content/Templates/
partialRootPath = EXT:siteconfig/Resources/Private/Extensions/fluid_styled_content/Partials/
layoutRootPath = EXT:siteconfig/Resources/Private/Extensions/fluid_styled_content/Layouts/
}
So these locations will be checked first, if no file is there for a certain contentelement, the version of fluid_styled_content will be used.
Check the original at /typo3/sysext/fluid_styled_content/Configuration/TypoScript/constants.txt
Make sure you keep the same subfolder structure for partials.

The problem was the line
lib.contentElement.templateRootPaths.100 = /fileadmin/template/Templates/
This line is wrong. There has to be no slash at the beginning of the path.
The right line reads:
lib.contentElement.templateRootPaths.100 = fileadmin/template/Templates/
I found that in the code example of the Templating Tutorial at https://docs.typo3.org/typo3cms/TemplatingTutorial/BasicFluidTemplates/Index.html.

Related

Add a static template to my typo3 extension

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.

TYPO3 (10.4) Felogin: Can´t change Template

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

setup.txt / setup.typoscript not being loaded in module

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.

Custom tags in TYPO3 content

new here, and also new to TYPO3.
I need to put something like [imagebox, title='box1'] into content editor and that will be replaced by a text and image with some javascript effect (text and image are managed in the DB elsewhere, the tag is just for the placement in the page).
I've read that TYPO3 has a mechanism for adding custom tags and I managed to make them accepted in the RTE.
I tried instead of [imagebox..... to use
<imagebox>box1</imagebox>
with something like this (copied from web):
tt_content.text.20.parseFunc.tags {
imagebox < lib.parseFunc.tags.link
imagebox = TEXT
imagebox.value= replaced
# imagebox = PHP_SCRIPT
# imagebox {
# stripNL = 0
# Pass a parameter from Typoscript to a PHP script:
# UID of the page containing the SINGLE view of tt_news
# id_singleView = 18
# Call the PHP script
# file = fileadmin/scripts/imagebox_parser.php
# }
}
lib.parseFunc.tags.imagebox < tt_content.text.20.parseFunc.tags.imagebox
should be able to replace content between tags.
I've commented call to php function just tried to get a text replacement for starters.
I've put that in the main root template Setup, but nothing is replaced.
I've also tried other examples from the web with no success.
Did anyone have situation like this?
Are there better approaches for that in TYPO3? (I'm using v7.6.23)
Any suggestion or hint is appreciated.
EDIT: using FSC on textmedia element
I think your examples are outdated. (the object PHP_SCRIPT is obsolete for a long time)
You might have a look at the documentation for your TYPO3 version:
https://docs.typo3.org/typo3cms/TyposcriptReference/7.6/Functions/Parsefunc/
you also need to enhance the parsefunc where you need it. That can depend on:
CSC or FSC?
which kind of content element (CE) do you use? (be sure to enhance the rendering of that CE)

Order of Constants TS in Template Analyzer

i'm struggeling with the order of typoscript in constants. I've a provider extension holding all the templates and files for the site. Typoscript ist used in external files, i don't want to store typoscript in the database. I use typo3_forum ext and want to modify the templates to customize it. But when i put the ts for the view like:
plugin.tx_typo3forum {
view {
templateRootPath = EXT:provider/Resources/Private/Templates/Forum/Standard/
partialRootPath = EXT:provider/Resources/Private/Partials/Forum/Standard/
layoutRootPath = EXT:provider/Resources/Private/Layouts/Forum/Standard/
}
}
these values will be overwritten by the typo3_forum ext itself, cause the constants of typo3_forum ext stands in the templateAnalyser hirachy under my provider extension.
Sure storing the above ts in the constants field of my roottemplate solves the problem but is there no solution for external fiels to sort?
I've tried:
plugin.tx_typo3forum.view.templateRootPaths.100 = EXT:provider/Resources/Private/Templates/Forum/Standard/
but this doens't work, the ext uses the default template in that case.
Thanks for your help!
Cheers Mark
Put your line
plugin.tx_typo3forum.view.templateRootPaths.100 = EXT:provider/Resources/Private/Templates/Forum/Standard/
in the setup, not in constants.
You can move the path to constants like
Constants:
plugin.tx_typo3forum.view.myTemplateRootPath = EXT:provider/Resources/Private/Templates/Forum/Standard/
Setup:
plugin.tx_typo3forum.view.templateRootPaths.100 = {$plugin.tx_typo3forum.view.myTemplateRootPath}
If using TYPO3 version 8, take a look at https://forge.typo3.org/issues/75862. There is a bug regarding the fallback for template paths. The issue has been solved already and is targeted for version 8.4
The order of TS appearing in the template analyser simply reflects the order in which the files are loaded.
If you are already using a provider extension for your TypoScript and don't put any TS statements in the database (which is a good practice) you can go one step further and put no extension TS in the database at all (not even include static templates in the template record).
Just include the TypoScript files that you need in your provider extension with <INCLUDE_TYPOSCRIPT and you have complete control of the order of things.
In the database you have to put just one line in constants and one in setup, each of the including from your provider extension. This will also make you less dependent of the database because if you include a new file it is just loaded and no actions are needed in the actual template record in the backend.