TYPO3 - Deactivating cHash in own extension - 8LTS - typo3

I'm trying to deactivate cHash in my extension ... the link for the show action looks like this:
/?tx_abc_abc[record]=1&tx_abc_abc[action]=show&tx_abc_abc[controller]=Abc&cHash=10c78febea3ae5dsdf535fb36ca6d08
In ext_localconf.php I tried to deactivate cHash like this:
ext_localconf.php
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.' . $_EXTKEY,
'Abc',
array(
'Abc' => 'list,show',
),
// non-cacheable actions
array(
'Abc' => 'list,show',
)
);
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_abc_abc[record],tx_abc_abc[action],tx_abc_abc[controller]';
It's not working though. What am I missing?

You need to deactivate the cHash when building the links in your template. If you are using the ViewHelper <f:link.action>, then you need to set the attribute noCacheHash="1".

For TYPO3 9 and 10
All we need to do is configure the parameter from which you don't want
your chash to be calculated
For example, your link is like this
<f:link.action action="detail"
additionalParams="{
tx_plugin_action:{
param1:1, param2:2, param3: 3
},
param4: 4
}">Link Text</f:link.action>
Then you have to exclude all the parameters in Localconfiguration.php
'FE' => [
'cacheHash' => [
'excludedParameters' => [
'tx_plugin_action[param1]',
'tx_plugin_action[param2]',
'tx_plugin_action[param3]',
'param4',
],
],
]
Additionally: Remember that if any of the parameter is not
included here then it will calculate and generate chash
Note: Here We don't need to set noCacheHash="1" explicitely in viewhelper

Related

TYPO3 V10 - EXT:news custom type and persistence mapping

i'm trying to upgrade a extension for TYPO3 10.4 which add a custom type to tx_news (Doc).
I did the migration based on this example: Breaking: #87623
Classes/Controller/NewsController.php
return [
\Xyz\Extendnews\Domain\Model\Team::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => 3,
],
But wenn I debug the entry in the Fluid-Template the default model is still used.
Did I miss something or does someone have a working example.
Thanks for any help.
Update:
I want to create a new type, explained in Georg RingerĀ“s manual
I have created a small extension, everything works fine with TYPO3 9.5, but not with TYPO3 10.4.
DEMO EXT
With TYPO3 10.4 the prototype is not MxnTeam\Domain\Model\Team
Update 29.06.2020:
tobenschmidt from the TYPO3 Slack channel ( post ) help me out.
return [
\Mexan\MxnTeam\Domain\Model\Team::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => \Mexan\MxnTeam\Domain\Model\Team::class,
],
\Mexan\MxnTeam\Domain\Model\Client::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => \Mexan\MxnTeam\Domain\Model\Client::class,
],
\GeorgRinger\News\Domain\Model\News::class => [
'tableName' => 'tx_news_domain_model_news',
//'recordType' => 0,
'subclasses' => [
\Mexan\MxnTeam\Domain\Model\Team::class,
\Mexan\MxnTeam\Domain\Model\Client::class,
]
],
];
This works fine, even with 2 custom types.
but unfortunately the default news are no longer loaded
but if I add recordType => 0, then only normal news and my custom types are visible, but not the type 1 and 2 (Internal and external)
I updated the extension:
mxn_team
is there a way to prevent this?
This works for me...
Implement your news type as described in https://docs.typo3.org/p/georgringer/news/8.5/en-us/DeveloperManual/ExtendNews/AddCustomType/Index.html
but instead of the described TypoScript add following file to your extension:
ext_name/Configuration/Extbase/Persistence/Classes.php
<?php
return [
\GeorgRinger\News\Domain\Model\News::class => [
'subclasses' => [
3 => \Vendor\ExtName\Domain\Model\MyCustomNewsType::class
]
],
Vendor\ExtName\Domain\Model\MyCustomNewsType::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => 3,
],
];
The way using TypoScript (config.tx_extbase.persistence.classes) was removed in TYPO3 v10
You write "Classes/Controller/NewsController.php" but you have to create a file here
extendnews/Configuration/Extbase/Persistence/Classes.php
and put your code in there. After that, do not forget to clear all cache.
Complete file "Classes.php" should look like
<?php
declare(strict_types = 1);
return [
\Xyz\Extendnews\Domain\Model\Team::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => \Xyz\Extendnews\Domain\Model\Team::class,
],
To use the new model follow Georg RingerĀ“s manual
manual on typo3.org
And a working example here

Backend module: Link to another backend module in TYPO3 9

Let's say I have to different extensions with two different backend modules. Registered like:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'Vendor.ext',
'ext',
'controller1',
'',
[
'Controller1' => 'any1',
],
[
'access' => 'user,group',
'icon' => '...',
'labels' => '...',
]
);
And in the second extension also like:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'Vendor.ext2',
'ext2',
'controller2',
'',
[
'Controller2' => 'any2',
],
[
'access' => 'user,group',
'icon' => '...',
'labels' => '...',
]
);
How can I build a link from ext1 in the module to ext2?
What did I tried before in FLUID was:
<f:link.action action="any2" controller="Controller2" extensionName="ext">click me</f:link.action>
or
<f:be.link route="/ext/Ext2Controller2/">click me</f:be.link> (by copying the route that's available via GET parameter)
No luck yet - any ideas? Or how to get the correct route if be.link would be the correct function?
Finally I found the reason.
It's simply possible to use the existing viewhelper like <f:be.link route="lux_LuxLeads">click me</f:be.link>
But the route must be the key and not the path. The key can be picked in the backend module configuration and backendroutes

What's the best way to site specific configuration in a multisite TYPO3 installation?

We have a TYPO3 9.5 installation with a bunch of different websites in it.
We want to store some custom configurations for each site (eg. show phone number in footer yes/no and something like this) and give the editors the possibility to change this in a simple way in the backend.
It would be nice if we can store these properties on the rootpage of each site but be able to overwrite (some) properties on sub pages if needed.
Similar to the page properties that fluidtypo3/flux brings.
Is there a possibility to achieve this with TYPO3 core and a custom extension? Eg. by extending the page table or adding custom table?
You need to differ between a site configuration and regular pages!
The site configuration is valid for the full site, so for every page
A page can be different on a page level
Both use cases are valid, so let's explain in detail
Extending the site configuration
The site configuration can easily be extended by creating the file <site-extension>/Configuration/SiteConfiguration/Overrides/sites.php
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function ($table) {
$GLOBALS['SiteConfiguration'][$table]['columns']['trackingCode'] = [
'label' => 'Label',
'config' => [
'type' => 'input',
'eval' => 'trim',
'placeholder' => 'GTM-123456',
],
];
$GLOBALS['SiteConfiguration'][$table]['types']['0']['showitem'] .= ',--div--;Extra,trackingCode';
},
'site'
);
The value of the new field trackingCode can then be easily fetched, e.g. by TS with data = site:trackingCode. As an alternative you can also use the SiteProcessor to get access to the site configuration in a FLUIDTEMPLATE.
Extending pages
Create the file <site-extension>/Configuration/TCA/Overrides/pages.php
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'pages',
[
'trackingCode' => [
'exclude' => true,
'label' => 'A label',
'config' => [
'type' => 'input',
]
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'pages',
'--div--;Extra, trackingCode'
);
and `ext_tables.sql``
CREATE TABLE pages (
trackingCode text NOT NULL
);
and you get access to the field with TypoScript and within FLUIDTEMPLATE with {data.trackingCode}.
Using slide
By adding trackingCode to the comma separated list in [FE][addRootLineFields] (use the Install Tool > Settings > Configure Installation-Wide Options it is possible to override the value for all subpages.
The following TypoScript will get up the rootline and return the 1st value set.
lib.code = TEXT
lib.code.data = levelfield:-1,trackingCode, slide

TYPO3 nocache for an specific page

I've got a big TYPO3 page with a self coded plugin. Now I want that all stuff which is done in this extension isn't cached.
For example all the inputs were cached and when I reload the page all fields are prefilled
what can I do?
If it's a extbase extension you write in ext_tables.php
<?php
defined('TYPO3_MODE') or die();
// Plugin
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.' . $_EXTKEY,
'Pluginname',
array(
'Plugin' => 'controller1',
),
// non-cacheable actions
array(
'Plugin' => 'controller1',
)
);
Or disable cache in Page > Setting > Behaviour > Cache > Disable

Adding new checkbox field to tx_news_domain_model_media

I am trying to add a new checkbox field 'showinhome' to the table 'tx_news_domain_model_media' same to the field 'showinpreview' here is my TCA Configuration in Configuration/TCA/Overrides/tx_news_domain_model_media.php
$temporaryColumns = [
'showinhome' => [
'exclude' => 1,
'label' => 'Show in Home',
'config' => [
'type' => 'check',
'default' => 0,
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tx_news_domain_model_media',
$temporaryColumns
);
$GLOBALS['TCA']['tx_news_domain_model_media']['ctrl']['label_alt'] .= ', showinhome';
$GLOBALS['TCA']['tx_news_domain_model_media']['interface']['showRecordFieldList'] .= ', showinhome';
$GLOBALS['TCA']['tx_news_domain_model_media']['palettes']['newsPalette']['showitem'] .= 'showinhome,';
The field is not displayed, can someone help me please?
You have mixed up some stuff here.
First: tx_news can use either the own media model or the native FAL relations. I personally always use the native FAL relation.
If you want to add this field to the media table, then there is no newsPalette there. You can use the below code to add the new field:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tx_news_domain_model_media', $temporaryColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_news_domain_model_media', implode(',', array_keys($temporaryColumns)));
If you using the normal FAL relation then the showinpreview field is added to the sys_file_reference table's TCA configuration and not to the tx_news_domain_model_media table.
If you want to add this field to the file, then you need to add it to the sys_file_reference field the same way tx_news does it (I guess that you already copied the code from it's override file)
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_reference', $temporaryColumns);
// add special news palette
$GLOBALS['TCA']['sys_file_reference']['palettes']['newsPalette']['showitem'] .= ', showinhome';
Last but not least: you have to specify tx_news as a dependency in your extension, otherwise TYPO3 does not know that your extension has to be loaded after tx_news. If you change the dependency after you installed your extension you probably need to uninstall and install it again in the extension manager.