Flexforms in extension without plugin - typo3

I have a extbase extension which inserts a content element over PageTSconfig:
NewContentElementWizard.ts:
mod.wizards.newContentElement.wizardItems.common {
elements {
tz_linkrow {
iconIdentifier = content-textpic
title = LLL:EXT:myext/Resources/Private/Language/locallang_db_new_content_el.xlf:wizards.newContentElement.myext_title
description = LLL:EXT:myext/Resources/Private/Language/locallang_db_new_content_el.xlf:wizards.newContentElement.myext_description
tt_content_defValues {
CType = myext_linkrow
}
}
}
show := addToList(linkrow)
}
Is there a possibility to use a flexform?
How can i insert it`?

Try this...
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$_EXTKEY,
'FILE:EXT:pf_spacer/Configuration/FlexForms/flexform_ds.xml',
'tz_linkrow'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tt_content', 'pi_flexform', 'myext_linkrow', 'replace:rowDescription');

Related

why Typo3 website v10 show empty sitemap xml in frontend

I'm using a Typo3 website version 10 and the sitemap is not working properly,
i can see the configuration in the typoscript object browser but in the front-end www.mydomain.ch/?type=1533906435 the xml file is blanc.
Frontend screenshot:
Typoscript object browser screenshot:
seo extension is installed.
the website is multilangage.
what can be missing so that i see the sitemap ?
If this is all you have, then you are missing some key configuration. You need to specify what should be shown. So, on your TypoScript, based on the documentation, you should define what pages/extension etc must be shown. For example:
plugin.tx_seo {
config {
xmlSitemap {
sitemaps {
pages {
config {
excludedDoktypes = 137, 138
additionalWhere = AND (no_index = 0 OR no_follow = 0)
#rootPage = <optionally specify a different root page. (default: rootPageId from site configuration)>
}
}
}
}
}
}
Here is an example for the extension news as well, in case you are using it.
plugin.tx_seo.config {
xmlSitemap {
sitemaps {
news {
provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
config {
table = tx_news_domain_model_news
additionalWhere =
sortField = sorting
lastModifiedField = tstamp
changeFreqField = sitemap_changefreq
priorityField = sitemap_priority
pid = 26
recursive = 2
url {
pageId = 25
fieldToParameterMap {
uid = tx_news_pi1[news]
}
additionalGetParameters {
tx_news_pi1.controller = News
tx_news_pi1.action = detail
}
}
}
}
}
}
}
Here the documentation as well: Documentation
i have solved the problem, i think it was the sourceopt extension installed have a bug, i have update it to the latest version, now i can see the xml sitemap working fine, thanks!

How to use DataProcessors with TYPO3 plugins

The way to add a DataProcessor to a PAGE or a FLUIDTEMPLATE is often shown. How can it be assigned to a TYPO3 plugin?
For a PAGE you can do it like this:
page {
10 {
dataProcessing {
1558428437 = BK2K\BootstrapPackage\DataProcessing\ConstantsProcessor
1558428437 {
as = myconstants
key = settings.constants
}
}
}
}
But can you do something like this:
config.tx_extbase {
dataProcessing {
1558428437 = BK2K\BootstrapPackage\DataProcessing\ConstantsProcessor
1558428437 {
as = myconstants
key = settings.constants
}
}
Many thanks!
No, this is not possible since data processors is a feature of the FLUIDTEMPLATE content object alone.
In this case you can invoke the ConstantsProcessor manually in your controller action. You can get the current ContentObjectRenderer via $this->configurationManager->getContentObject(). The $processorConfiguration is the same as in TypoScript but as array:
$constantsProcessor = GeneralUtility::makeInstance(ConstantsProcessor::class);
$data = $constantsProcessor->process(
$this->configurationManager->getContentObject(),
[],
[
'key' => 'settings.constants',
'as' => 'myconstants',
],
[]
);
// Use $data['myconstants']
That's currently not possible.
This would definitely be a feature that would make live of Integrators much easier.

typolink userFunc in TYPO3 V8

I want to use the core linkhandler and change my link in a userFunc.
I use the linkhandler as it is described here, and it works with a single detail page:
https://usetypo3.com/linkhandler.html
The problem is:
If i change my typoscript to:
config.recordLinks {
tx_news {
typolink {
userFunc = Vendor\Name\UserFunc\TypolinkUserFunc->parseLinkHandlerTypolink
userFunc {
newsUid = TEXT
newsUid.data = field:uid
newsClass = TEXT
newsClass.data = parameters:class
defaultDetailPid = 53
}
}
}
}
it doesn't work.
I cannot address the userFunc. I'm in an extension. i use
'autoload' =>
array(
'psr-4' => array('Vendor\\Name\\' => 'Classes')
),
);
in order to load my userFunc Class.
I do not get any error message.
You must have figured it out by now, but you have to run a userFunc as USER.
10 = USER
10 {
userFunc = TYPO3\Extension\Sample->user_exampleUserFunc
}
So as a sample, your code should look something like this:
config.recordLinks {
tx_news {
typolink {
10 = USER
10 {
userFunc = Vendor\Name\UserFunc\TypolinkUserFunc->parseLinkHandlerTypolink
userFunc {
newsUid = TEXT
newsUid.data = field:uid
newsClass = TEXT
newsClass.data = parameters:class
defaultDetailPid = 53
}
}
}
}
}
As the above is just an example, it should get you started.

typoscript variable in plugin settings?

I am using a custom plugin and I need to add the page title as one of the plugin's settings variables:
plugin.tx_fsearch {
settings {
resultsPath = search-results/brand/{field:title}/make/{field:title}
resultsPath.insertData = 1
}
}
However this is outputting the word 'Array' instead of the path I need.
Does anyone know how I might be able to make this work?
There is no stdWrap available for settings in extbase extensions, no matter if using TEXT cObj or insertData!
As a workaround, you can fix that yourself by doing something like EXT:news does here https://github.com/georgringer/news/blob/master/Classes/Controller/NewsController.php#L495
public function injectConfigurationManager(
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
) {
$this->configurationManager = $configurationManager;
$typoScriptService = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Service\TypoScriptService::class);
$typoScriptArray = $typoScriptService->convertPlainArrayToTypoScriptArray($originalSettings);
$stdWrapProperties = GeneralUtility::trimExplode(',', $originalSettings['useStdWrap'], true);
foreach ($stdWrapProperties as $key) {
if (is_array($typoScriptArray[$key . '.'])) {
$originalSettings[$key] = $this->configurationManager->getContentObject()->stdWrap(
$originalSettings[$key],
$typoScriptArray[$key . '.']
);
}
}
}
$this->settings = $originalSettings;
}
Or you skip the TS part and call the stdWrap directly in your controller.
Try TEXT object
plugin.tx_fsearch {
settings {
resultsPath = TEXT
resultsPath.value = search-results/brand/{field.title}/make/{field.title}
}
}

Set templavoila template with typoscript

Is it possible to set a page's templavoila template with typoscript?
I have solved it with:
includeLibs.lang = fileadmin/user_tvtest.php
page.1 = USER_INT
page.1.userFunc = user_tvtest->main
page.10 = USER_INT
page.10.userFunc = tx_templavoila_pi1->main_page
page.10.disableExplosivePreview = 1
and in fileadmin/user_tvtest.php:
class user_tvtest
{
function main($content, $conf)
{
if (is_mobile())
{
$GLOBALS['TSFE']->page['tx_templavoila_to'] = 7;
//$GLOBALS['TSFE']->page['tx_templavoila_ds'] = 7;
}
}
}
http://daschmi.de/templavoila-template-domainbezogen-umschalten-gleicher-seitenbaum/
Look how the page is configured by TemplaVoila:
page = PAGE
page.typeNum = 0
page.10 = USER
page.10.userFunc = tx_templavoila_pi1->main_page
page.shortcutIcon = {$faviconPath}
They call the main_page function of class tx_templavoila_pi1 via page.userFunc:
/**
* Main function for rendering of Page Templates of TemplaVoila
*
* #param string Standard content input. Ignore.
* #param array TypoScript array for the plugin.
* #return string HTML content for the Page Template elements.
*/
function main_page($content,$conf) {
$this->initVars($conf);
// Current page record which we MIGHT manipulate a little:
$pageRecord = $GLOBALS['TSFE']->page;
// Find DS and Template in root line IF there is no Data Structure set for the current page:
if (!$pageRecord['tx_templavoila_ds']) {
foreach($GLOBALS['TSFE']->tmpl->rootLine as $pRec) {
if ($pageRecord['uid'] != $pRec['uid']) {
if ($pRec['tx_templavoila_next_ds']) { // If there is a next-level DS:
$pageRecord['tx_templavoila_ds'] = $pRec['tx_templavoila_next_ds'];
$pageRecord['tx_templavoila_to'] = $pRec['tx_templavoila_next_to'];
} elseif ($pRec['tx_templavoila_ds']) { // Otherwise try the NORMAL DS:
$pageRecord['tx_templavoila_ds'] = $pRec['tx_templavoila_ds'];
$pageRecord['tx_templavoila_to'] = $pRec['tx_templavoila_to'];
}
} else break;
}
}
// "Show content from this page instead" support. Note: using current DS/TO!
if ($pageRecord['content_from_pid']) {
$ds = $pageRecord['tx_templavoila_ds'];
$to = $pageRecord['tx_templavoila_to'];
$pageRecord = $GLOBALS['TSFE']->sys_page->getPage($pageRecord['content_from_pid']);
$pageRecord['tx_templavoila_ds'] = $ds;
$pageRecord['tx_templavoila_to'] = $to;
}
return $this->renderElement($pageRecord, 'pages');
}
This function checks the current page or search trough the rootline (TSFE) for the configured page template. The script does not check any TypoScript settings at all so I suppose thats not supported by TemplaVoila right now.
It should not be too hard extending this class with a custom function that will check some TypoScript settings.