TYPO3 8, Form extension - best practice for custom yaml files - forms

When generating forms with the form module the corresponding yaml files get stored in fileadmin/user_upload.
Now I want to integrate those yaml files into my sitepackage and thus into my CVS. Where is the correct place for them? In the example extension they are stored in Resources/... while I would think they have to go into Configuration/Yaml
And how do I configure the form extension to search them in that place?

While it's basically a matter of taste where exactly one saves his form definitions, I try to separate form configuration and form definitions.
From the official documentation:
[...] the form configuration allows you to define:
which form elements, finishers, and validators are available,
how those objects are pre-configured,
how those objects will be displayed within the frontend and backend.
In contrast, the form definition describes the specific form,
including
all form elements and their corresponding validators,
the order of the form elements within the form, and
the finishers which are fired as soon as the form has been submitted.
Furthermore, it defines the concrete values of each property of the mentioned aspects.
So, for more clarity I save all form configuration in a sitepackage under Configuration/Yaml/ and the form definitions under Resources/Private/Forms, neighbouring the templates.
I wrote a full tutorial how to use custom templates with EXT:form, which also includes the answers to your question.
In short:
Register YAML configuration with TypoScript in your extension root folder as ext_typoscript_setup.txt (as recommended1)
plugin.tx_form.settings.yamlConfigurations {
100 = EXT:my_extension/Configuration/Yaml/CustomFormSetup.yaml
}
module.tx_form.settings.yamlConfigurations {
100 = EXT:my_extension/Configuration/Yaml/CustomFormSetup.yaml
}
CustomFormSetup.yaml – setting up a new storage path
TYPO3:
CMS:
Form:
persistenceManager:
allowedExtensionPaths:
10: EXT:my_extension/Resources/Private/Forms/
allowSaveToExtensionPaths: true
allowDeleteFromExtensionPaths: true
1TypoScript inside an ext_typoscript_setup.txt is automatically loaded in both frontend and backend of your TYPO3 installation directly after installing your extension. This differs from other TypoScript files, which have to be included manually, e.g. as static templates. See official Form Framework documentation.

I'd suggest Resources/Private/Forms for your form definitions. The form extension clarifies how to register additional form definition paths.

Related

TYPO3: Where can I find the template created in the backend?

I'm trying to create separate templates for webpages with either a single or a double column structure. Currently my webpage only has one template, placed on the root page which is used by all its subpages.
However, I cannot find the template in myextension/Resources/Private/Templates as this folder is empty. Where is the template located in my extension and where should I add the alternative template?
I assume you use "fluid_styled_template"? Then the templates are in that respective core directory, in "Resources/Private".
If you want to manipulate them, copy them to your sitePackage into "Resources/Private/Extension/fluid_styled_content" (that at least is one of the recommended ways where to place it) and override the TypoScript that "fluid_stlyed_content" provides.
templateis not unique in TYPO3 context. we have:
typoscript records, maybe also as files which are included in a record or by PHP
HTML files, which are define a markup for parts of the website
they can be differed in
Marker-Templated. The old and less and less used kind with markers and subparts as placeholders for data defined in typoscript
Fluid templates. The modern kind with control structures and data objects
with the statemant
my webpage only has one template, placed on the root page
it is not clear what you mean:
records are defined in pages -> typoscript templates
maybe you mean in the root page a template is selected. that could mean HTML templates, probably fluid templates as the path myextension/Resources/Private/Templates matches the usual structure for fluid templates.
assuming fluid templates:
Templates are search in a list of folders. This list is managed in typoscript.
Any usage has it's own list and the list of your main/page template probably is at page.10.templatePaths. You can look for it in the TSOB (Typoscript Object browser)
If the list consists of one entry only you have only the basic config.
As the list of folders is consulted each time a template (,partial, layout) is accessed and only that file with matching name in the folder with highest priority is taken you can add your folders with higher numbers in the list so you do not need to change the original files (use copies in your folder to modify) or add files to the original folder (inside of other extensions).
So you need two things:
create your template file in an appropriate folder
(ext:myextension/Resources/Private/Templates sounds good)
and add this folder to the list of folders for these templates
(e.g. page.10.templatePaths.20 = EXT:myextension/Resources/Private/Templates)

How to get the Log In Form on every page? (for example in footer) Typo3

Is there a way to get the Log In Form for Frontend User on every page? I would prefer the footer.
And if someone is logged in you can see the Log Out Button.
Is this possible without an extension?
You can copy the default felogin output to wherever you want on your template. For example use lib.login, copy the plugin.tx_felogin_pi1 into it, change the template and you're fine.
lib.login < plugin.tx_felogin_pi1
lib.login.templateFile = path/to/your/template/file
More you can see in the official documentation: https://docs.typo3.org/typo3cms/extensions/felogin/8.7/Configuration/Index.html
In general there are three options to include a CE (e.g. the Login-form) on all pages:
use typoscript to generate the CE. Normally the CEs are defined in tt_content, from where you could copy the base configuration and adapt it. For some plugins you also find a complete configuration beyond lib (for newer extensions there you only find the settings). All the configuration must be done in typoscript.
use typoscript to render the content of a special page/ column. In this variant you have a special page only for content referenced somewhere else. Advantage: you could configure the CE in the usual way. Try to avoid referencing CEs by uid as an editor might disable or delete the current element(s) and insert a new one which would not be rendered.
use a special column in your root page and inherit the content to all subpages. Advantage: you could change the inherited content easily on each page (if this column is available in the current backend layout).
example for 3:
variables {
footer_content < styles.content.get
footer_content.select.where = colPos = 15
footer_content.slide = -1
}

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.

Fluidpages Flux Configuration inheritance incomplete

I'm currently using TYPO3 6.1.8-dev to build a flux/fluidpages (GitHub Master) powered template and managed to have it running on the root pages, though, I have issues with the sub-pages, in terms of value inheritance.
I've implemented the following scenario:
A Flux Flexform Configuration is used, if there is no TypoScript override variable set, retrieved from TS Setup.
The Flexform fields have the following names:
gridsettings.topRow_use (checkbox)
gridsettings.topRow_cols (select)
After the Flexform Configuration, I use these fields to build the backend grid, after I mix in some static values of a TypoScript configuration with:
{v:iterator.merge(a:'{gridsettings}', b:'{tssettings}') -> v:var.set(name:'gridsettings')}
This works for every page with explicit settings in the page properties, but not for sub-pages, which should just inherit the parents settings.
In the case of sub-pages the gridsettings array is null, and only my TS settings are visible.
I'd like to have the convenience to just create a new sub-page, and add content to the inherited backend-layout grid without any further interaction in the page settings.
How can I solve this issue?
Two parts to this:
1) To solve the problem that you manually must merge TS with FlexForm settings, use the prefix settings. in all your field names. This special, reserved variable name will be used by both Extbase and Fluid without requiring you to transfer it, and your FlexForm settings will be merged (on top of) your TS settings.
2) Inheritance requires the exact same page template on parent and child page, or that child page sets parent decides as option for which template to use. There could be other causes for failing inheritance (for example, the use of default on any of your fields - since you don't include your Flux form structure this is impossible to determine) but mismatching parent/child template is the most common. Also, make sure your Flux is up-to-date; there have been bugfixes recently related to inheritance.

Typo3: Reference about TSFE array

Where can be found references about the $GLOBALS['TSFE'] variable for typo3?
For example some code snippets report that "TSFE:id" is the id of the current page, but where can I find the reference about this variables?
There is none. Really :-(.
But you also must know that $GLOBALS['TSFE'] (TypoScript Frontend) is not just an array containing some information, TSFE also consists of objects that can be used by extensions or in TypoScript context to access data from the current page or user. E.g.
$GLOBALS['TSFE']->sys_page is an instance of \TYPO3\CMS\Frontend\Page\PageRepository
$GLOBALS['TSFE']->fe_user is an instance of \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication
So basically the documentation is spread all over the TYPO3 documentation. You will also realize that a lot of the information can be accessed or used by TypoScript or TYPO3 API without needing to parse the TSFE array.
There used to be a (incomplete) section on TYPO3's wiki, but it seems to be gone now. You can find it on the wayback machine though:
https://web.archive.org/web/20130621221807/http://wiki.typo3.org/TSref/getText
The only online "documentation" that I know of is the TYPO3 source of the TypoScript Frontend Controller (a.k.a. TSFE):
https://api.typo3.org/TYPO3_8-7/_typo_script_frontend_controller_8php_source.html
It's all of the public properties you can access directly via TS:
10 = TEXT
10.data = TSFE:fe_user|user|username