Related to How to add custom wizards in typo3 7 TCA? how can costum wizards in TYPO3 9 be implemented? I've added my entry to the Routes.php
return [
'tx_csseo_preview' => [
'path' => '/wizard/tx_csseo/preview',
'target' => \Clickstorm\CsSeo\UserFunc\PreviewWizard::class . '::render'
],
'tx_csseo_permalink' => [
'path' => '/wizard/tx_csseo/permalink',
'target' => \Clickstorm\CsSeo\UserFunc\PermalinkWizard::class . '::render'
]
];
How can I add them now to my TCA field?
'tx_csseo_title' => [
'label' => 'LLL:EXT:cs_seo/Resources/Private/Language/locallang_db.xlf:pages.tx_csseo_title',
'exclude' => 1,
'config' => [
'type' => 'input',
'max' => $extConf['maxTitle'],
'eval' => 'trim',
'fieldWizard' => [
'tx_csseo_preview' => [
'disabled' => false,
]
]
]
],
This does not work. What do I miss? Thanks in advance.
Related to your kind of wizard the registration-process is different and extensive explained here. You can leave the entries in Routes.php away (perhaps even the whole file if nothing else is inside).
Registration is done in ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1485351217] = [
'nodeName' => 'importDataControl',
'priority' => 30,
'class' => \T3G\Something\FormEngine\FieldControl\ImportDataControl::class
];
Then reference the new wizard in TCA:
'somefield' => [
'label' => $langFile . ':pages.somefield',
'config' => [
'type' => 'input',
'eval' => 'int, unique',
'fieldControl' => [
'importControl' => [
'renderType' => 'importDataControl'
]
]
]
],
Then finally the class with the "magic"
declare(strict_types=1);
namespace T3G\Something\FormEngine\FieldControl;
use TYPO3\CMS\Backend\Form\AbstractNode;
class ImportDataControl extends AbstractNode
{
public function render()
{
$result = [
'iconIdentifier' => 'import-data',
'title' => $GLOBALS['LANG']->sL('LLL:EXT:something/Resources/Private/Language/locallang_db.xlf:pages.importData'),
'linkAttributes' => [
'class' => 'importData ',
'data-id' => $this->data['databaseRow']['somefield']
],
'requireJsModules' => ['TYPO3/CMS/Something/ImportData'],
];
return $result;
}
}
In the linked example there is still an Ajax Route with corresponding files, including a special defined route, but that's not required to get the basic wizard shown.
Concerning the registration in ext_localconf.php there is above the number 1485351217 as array-key shown. For an own registered node just calculate once the current time as unix-timestamp and enter that instead. So it's unique and can't be mistaken with other definitions of any registered nodes.
In contrast to the linked example I used slightly different descriptions, so I call the process in ext_localconf.php registering, and the inclusion in TCA referencing. Perhaps this small difference makes it a bit more clear.
Icons
Concerning Icons there is still a difference to earlier TYPO3 versions, they have to be registered now too and in TCA they are only referenced too by the registered name. Here in the TCA-file is no icon referenced but the class below makes usage of it. Here is an example how an icon has to be registered in ext_tables.php:
$systemIconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$systemIconRegistry->registerIcon(
'imagemapwizard_link_edit',
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
[
'source' => 'EXT:imagemap_wizard/Resources/Public/Icons/link_edit.png'
]
);
The new icon registry is implemented starting with TYPO3 version 7.5
Don't forget the configuration in YourExtension/Configuration/Backend/AjaxRoutes.php. See the documentation
Related
I need to save the IP address of a user who fills out my form.
I have tried to do it like this:
'userip' => [
'exclude' => true,
'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myextension_domain_model_myextension.userip',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => '12345'.$_SERVER["REMOTE_ADDR"]
]
],
But that doesn't work. What would be the right way?
$_SERVER["REMOTE_ADDR"] is not available in TCA cause this is BE related stuff.
Use the setter from the model, setUserip($_SERVER["REMOTE_ADDR"]), in your createAction() or initializeCreateAction() to save the value in DB.
I'm trying to add a CSS class selection in a TCA inputLink Field. I was able to create the selection in the RTE Editor and now I want to be able to select the same CSS classes in TCA link input fields.
Here is my current code:
'link' => [
'exclude' => 1,
'label' => 'foo label',
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'size' => 50,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'options' => [
'title' => 'foo title',
'class' => [
'valuePicker' => [
'mode' => 'blank',
'items' => [
['button', 'Button Style'],
],
],
],
],
],
],
'softref' => 'typolink',
],
],
I couldn't find anything in the TCA Docs. I thought I would give it a try with the LinkPopup --> options --> class. But (as expected) nothing happens.
How am I able to define such a selection dropdown in the link input field?
I'm using TYPO3 LTS 11.
Not sure if you have configured, what you are describing...
A valuePicker can be placed next to an input field of RenderTypes default, colorpicker, inputLink (-> TCAref). The class field in the linkPopup is a simple (hardcoded) form field without a defined renderType or other TCA configuration (Code insight).
There are only a few options for configuring a linkpopup (-> TCAref):
pid
allowedExtensions
blindLinkFields
blindLinkOptions
Setting a prefilled (not selectable) class seems to be possible via TCAMAIN.linkHandler-options (-> LinkBrowser-API). I found an example in an issue of EXT:bootstrap_package.
I've come accross a weird issue with extbasewhile working on some semi-complicated logic for filtering of courses for a LMS tools that we work on.
The logic is as follows:
There are course templates and seminars
A course template always has a start and end date, it contains courses that depend on one another
A seminar contains multiple courses that do not depend on one another
As long as a course template starts after the selected date, it has to be displayed
As long as a seminar contains a course that starts after the selected date, it has to be displayed
There are other filters that do not matter here and that do not play into this issue
In order to solve this request, I resorted to the power of extbase being able to simply create a subquery by using something like $query->greaterThanOrEqual('template_children.start_date', $date) (see below for concrete example). This now generates the below result:
Resulting SQL:
SELECT `tx_xxx_domain_model_courseprogrammetemplate`.*
FROM `tx_xxx_domain_model_courseprogrammetemplate`
`tx_xxx_domain_model_courseprogrammetemplate`
LEFT JOIN `tx_xxx_domain_model_courseprogrammetemplate`
`tx_xxx_domain_model_courseprogrammetemplate0`
ON Find_in_set(
`tx_xxx_domain_model_courseprogrammetemplate0`.`uid`,
`tx_xxx_domain_model_courseprogrammetemplate`.`template_children`)
The relations are built by an important and there are no values written to the field template_children on this side of the relation, thus no result is found.
AFAIK, this should work without having to populate this field with anything else than maybe an amount of children (and I'm not sure if this is even necessary anymore).
Here's my TCA configuration and the PHP code handling the logic.
TCA:
'template_children' => [
'exclude' => true,
'label' => 'LLL:EXT:xxx/Resources/Private/Language/locallang_db.xlf:tx_xxx_domain_model_courseprogrammetemplate.template_children',
'config' => [
'items' => [
['', 0]
],
'type' => 'select',
'renderType' => 'selectSingleBox',
'foreign_table' => 'tx_xxx_domain_model_courseprogrammetemplate',
'foreign_table_where' => 'AND tx_xxx_domain_model_courseprogrammetemplate.template = ###REC_FIELD_uid### AND tx_xxx_domain_model_courseprogrammetemplate.sys_language_uid = 0',
'readOnly' => 1,
'size' => 5,
'maxitems' => 100,
'autoSizeMax' => 20,
],
],
Extbase:
$constraints[] =
$query->logicalAnd(
[
$query->logicalOr(
[
// If the learning form is a course, the start and end date should be in between the period
$query->logicalAnd(
[
$query->greaterThanOrEqual('start_date', $demand->getStartDate()->format('Y-m-d H:i:s')),
$query->logicalNot($query->equals('learning_form', 'Seminar'))
]
),
// If the learning form is seminar, we only want to display it, if there is at least one course that starts in this period
$query->logicalAnd(
[
$query->logicalOr(
[
$query->greaterThanOrEqual('templateChildren.start_date', $demand->getStartDate()->format('Y-m-d H:i:s')),
]
),
$query->equals('learning_form', 'Seminar')
]
)
]
)
]
);
I tried switching the TCA field type to inline but this didn't change the behaviour.
Another way to do this would be to get all objects that relate to each seminar that match the filter, but that would mean creating some thousands of separate queries while filter :-/
Thanks for your support.
PS: I found this article, but it does not describe, how to configure the TCA accordingly, so that it works:
TYPO3 Extbase: Filtering a 1:N relation
Also sadly the documentation doesn't say much about what to configure how in TCA for this to work:
https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/6-Persistence/3-implement-individual-database-queries.html
I ended up finding the solution to my problem: you have to use inline as a type so that extbase has a chance to know how to resolve the relation:
'template_children' => [
'exclude' => true,
'label' => 'LLL:EXT:xxx/Resources/Private/Language/locallang_db.xlf:tx_xxx_domain_model_courseprogrammetemplate.template_children',
'config' => [
'items' => [
['', 0]
],
'type' => 'inline',
'foreign_table' => 'tx_xxx_domain_model_courseprogrammetemplate',
'foreign_field' => 'template',
'appearance' => [
'collapseAll' => 1,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
],
'overrideChildTca' => [
'ctrl' => [
'types' => [
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title'],
],
],
],
],
],
I want to format the title showing in a list of TCA items which can contain italic text. But whatever I try, I get only unformatted text - even from RTE text fields.
My base information is "partA", "partB", "partC" and I need a title like "partA : partC - part B"
My Code so far:
<?php
return [
'ctrl' => [
'title' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem',
'label' => 'partC',
'label_alt' => 'partA',
'formattedLabel_userFunc' => T395\myExt\Classes\UserFuncs\MyBEUserFuncs::class.'->getFullMyitemTitle',
'formattedLabel_userFunc_options' => [
'sys_file' => [
'partC','partA','partB'
]
],
'iconfile' => 'fileadmin/Resource/icons/svgs/myext.svg',
],
'columns' => [
'partC' => [
'label' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem.partC',
'config' => [
'type' => 'text',
'enableRichtext' => true,
],
],
'partA' => [
'label' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem.partA',
'config' => [
'type' => 'input',
'size' => '5',
'eval' => 'trim',
],
],
'partB' => [
'label' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem.partC',
'config' => [
'type' => 'input',
'size' => '5',
'eval' => 'trim',
],
],
],
'types' => [
'0' => ['showitem' => 'partA,partB,partC'],
],
];
And the UF:
<?php
T395\myExt\Classes\UserFuncs;
class MyBEUserFuncs
{
public function getFullMyitemTitle(&$params, &$pObj)
{
echo "Hello World!";
$params['title'] = $params['row']['partA'].' : '.$params['row']['partC'].' - '.$params['row']['partB'];
}
}
Even the echo is not showing. Changing the formattedLabel_userFunc to label_userFunc results in getting a string in right order - but right without any text formats like <i> etc but showing them as text. I'm sure, I'm missing something, but I can't figure out what it is - I was also unable to find any code snippets or examples showing the right way - and the docs from TYPO3 saying only that exists formattedLabel_userFunc and it has options - but no proper example there. Hope you can help me. Thank you!
in the documentation for formattedlabel_userfunc you can find:
[...] return formatted HTML for the label and used only for the labels of inline (IRRE) records.
and for label_userfunc there is the warning:
The title is passed later on through htmlspecialchars() so it may not include any HTML formatting.
we follow this youtube link to create yii2+mongodb connection but not working. check this link: https://www.youtube.com/watch?v=1msu95ZkRe8
gives an error Object configuration must be an array containing a "class" element.
in video user.php model copy paste from doc file what is that file please help me.
I successfully realized the login service at my own project using MongoDB. But I didn't use video tutorial you pointed out.
It looks like you have an error in your configuration file. I would first check the config for mongodb component. It must be something like following (yii2-mongodb project README)
return [
//....
'components' => [
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://developer:password#localhost:27017/mydatabase',
],
],
];
Other component is worth checking out is the user component:
return [
//....
'components' => [
'user' => [
'identityClass' => 'frontend\models\User', // This is your class with IdentityInterface
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
],
];
But in fact, similar error may appear for any configuration element of YII2.
as per video change below function behaviors in comman/models/User.php
public function behaviors()
{
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
]
]
];
}