TYPO3 nocache for an specific page - typo3

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

Related

TYPO3 9.5.x with news 7.2.x: Custom properties

I've extended TYPO3 9.5.x with news extension 7.2.x with some custom properties.
I used the manual I found here.
In general, everything works, but somehow the custom properties I created seem to be blank at the frontend. After clearing the cache, everything works again, but after some time the same issue appears again.
What am I doing wrong? Maybe it has something to do that I'm working with TYPO3 9.5.x and the manual is written for TYPO3 7.6.x?
Thanks for your help!
move your TCA modifying code (from ext_tables) to /typo3conf/ext/yourEXT/Configuration/TCA/Overrides/tx_news_domain_model_news.php
something like this:
defined('TYPO3_MODE') or die();
( function( &$tca) {
$tempColumns = array(
'NEW_FIELD' => array(
'exclude' => 0,
'label' => 'LLL:EXT:yourEXT/Resources/Private/Language/locallang_be.xlf:tx_newsextend_domain_model_news.NEW_FIELD',
'config' => array(
'type' => 'check',
'default' => 0
),
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tx_news_domain_model_news',
$tempColumns
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes("tx_news_domain_model_news", 'NEW_FIELD', '', 'after:title');
})( $GLOBALS['TCA']['tx_news_domain_model_news']);

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 - Deactivating cHash in own extension - 8LTS

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

plugin.xx.view.pluginNamespace = Controller are not allowed by this Plugin

I have started a extension under TYPO3 6.2, and migrated this to TYPO3 7. Now it seems, that all links to Controller/Action combinations are broken.
In my TypoScript I have set:
plugin.tx_extensionname.view.pluginNamespace = tx_extensioname
In ext_tables.php I have set:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Pi1',
'Controller1: DoSomeLogic1'
);
....
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Pi12',
'Controller12: DoSomeLogic12'
);
In ext_localconf.php the plugins get configured:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MRU.' . $_EXTKEY,
'Pi2',
array(
'Basket' => 'list, add, remove, address, setDeliveryCountryJson',
'Order' => 'directorder, savedirectorder, accountorder, loginorder, saveloginorder, saveaccountorder, overview, doOrder, paymentSuccess, paymentFailure, paymentNotification, paymentCancel',
'Payment' => 'index'
),
// non-cacheable actions
array(
'Basket' => 'list, add, remove, address, setDeliveryCountryJson',
'Order' => 'directorder, savedirectorder, accountorder, loginorder, saveloginorder, saveaccountorder, overview, doOrder, paymentSuccess, paymentFailure, paymentNotification, paymentCancel',
'Payment' => 'index'
)
);
On a page (id 42) I have placed the plugin Pi2. The Basket Controller is shown with list action. All fine. The URL is like this:
http://www.example.com/index.php?id=42
If I add the namespaced Controller Parameter, like this
http://www.example.com/index.php?id=42&tx_extensionname[controller]=Basket
I get instantly the
#1313855173: The controller "Basket" is not allowed by this plugin. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.
Exception. If I add the pluginname to the URI like this
http://www.example.com/index.php?id=42&tx_extensionname_pi2[controller]=Basket
no expecption is thrown. But if I call a action like this
http://www.example.com/index.php?id=42&tx_extensionname_pi2[controller]=Basket&tx_extensionname_pi2[action]=add
this action gets never called. The Controller with it's first action is called.
I did the update some weeks ago, it is only a dev system, but today I cleared all caches and the error occours. Have I missed something with plugin combined namespaces and the registration/configuration/linking of it?
Ok, it seems that this resolve my issue:
plugin.tx_extensionname.mvc.callDefaultActionIfActionCantBeResolved = 1
With callDefaultActionIfActionCantBeResolved = 0 or missing the above, i get the Not Allowed Exception. Settings this to 1 the Controller and Action gets called.

How to add custom wizards in typo3 7 TCA?

When I try to add the wizard named wizard_geo_selector in TCA ,there arised an error "module not registered".Please tell me how to register the wizard properly in the TCA.?
In TYPO3 Version 7.6 new wizards are added like this:
Inside your extension create the directory Configuration/Backend/
In the new directory create a file Routes.php, it will be found automatically, no mentioning in ext_localconf.php or ext_tables.php is required. If you still need Ajax you can add the file AjaxRoutes.php in the same folder.
Content for Routes.php:
return array(
'my_wizard_element' => array(
'path' => '/wizard/tx_geoselecotor/geo_selector_wizard',
'target' => \Path\To\your\class\WizardGeoSelector::class . '::WizardAction'
),
);
Content for AjaxRoutes.php
<?php
/**
* Definitions for routes provided by EXT:backend
* Contains all AJAX-based routes for entry points
*
* Currently the "access" property is only used so no token creation + validation is made
* but will be extended further.
*/
return array('my_ajax_element' => array(
'path' => 'tx_geoselecotor/my_ajax_route',
'target' => \Path\To\your\class\MyAjaxController::class .'::myAjaxFunction'
));
If you're unsure about the notation you can compare with existing entries in the Global Variables in the Backend:
Navigate to System -> Configuration -> Backend Routes
The route of the paths is handled different, for Ajax it's always "ajax" prepended, so you've never to add it to the path, else it's twice in the route. For the common route there is no change concerning the defined string.
Now the wizard can be used and even it never has to be defined in ext_tables.php it has to be mentioned there from any table-field in the configuration-area (module[name]):
'table_field_for_wizard' => array(
'label' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xml:table_name.tx_myextension_wizard',
'config' => array (
'type' => 'user',
'userFunc' => 'Path/to/class/without/wizard->renderForm',
'wizards' => array(
'my_wizard' => array(
'type' => 'popup',
'title' => 'MyTitle',
'JSopenParams' => 'height=700,width=780,status=0,menubar=0,scrollbars=1',
'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/img/link_popup.gif',
'module' => array(
'name' => 'my_wizard_element',
'urlParameters' => array(
'mode' => 'wizard',
'ajax' => '0',
'any' => '... parameters you need'
),
),
),
'_VALIGN' => 'middle',
'_PADDING' => '4',
),
# Optional
#'softref'=>'something',
),
),
In the userFunc Path/to/class/without/wizard->renderForm you've to create a button which is linking to the wizard and onClick the wizard will open with the route you defined in Routes.php and the optional urlParameters.
Currently I never found this whole item explained in the core-documentation.
Edit:
Details about routing can be found here: Routing
The rendering process can be found here: Rendering / NodeFactory
You should probably read also the outer context of the linked paragraph.
Edit 2:
An example extension can be found here, some things never work 100% but the wizard is working. The extension is for TYPO3 Version 7:
https://github.com/DavidBruchmann/imagemap_wizard
Ricky's answer doesn't really work anymore, since addModulePath ist deprecated since version 7.
Also, just registering the module like this still give's you said error.
The only thing that keeps the wizard going again is this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('wizard','pbsurvey_answers',"",\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY).'wizard/');
But when you add this, the module appears as a new point in your TYPO3 backend.
IN TCA add the wizard like follows:
'module' => array(
'name' => 'wizard_geo_selector',
),
In ext_tables.php register the wizard.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
'wizard_geo_selector',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/Yourwizardname/'
);
Keep in mind this is deprecated since Typo3 7 and removed in Typo3 8.So you can use this method upto Typo3 7.For Typo3 8 do use the method specified by David below.