Debug / var_dump
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Core\Utility\DebugUtility;
[...]
DebuggerUtility::var_dump($this->settings['showPassedEvents']);
DebugUtility::debug)(
Display Errors in FE
You need to switch off the "Content Object Exception Handler", which is an exception handler in new versions. If a content element/plugin throws an exception, it does no longer take down the whole site, but only itself. To disable it, set
config.contentObjectExceptionHandler = 0
Don't forget to re-enable the exception handler when going live, and in your live system, you can find the exception trace in your log files. Basically what Viktor Livakivskyi says in the other answer.
Update auf 12
- TCA: image files (old definition leads to "Unknown column 'sys_file_reference.table_local' in 'where clause'")
- Registration of Backend Modules
- "Invoked ContentObjectRenderer::parseFunc without any configuration" beim Benutzen von <f:format.html>. Evtl. nur im Backend? Evtl. steht dort lib.parseFunc_RTE nicht zur Verfügung?
Setup
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:myext/Configuration/TypoScript/mainSetup.ts">
Call Page/File etc: PSR-7 request
use Psr\Http\Message\RequestFactoryInterface;
$baseUri = $this->getBaseUri( $this->request ) . '/webapi/typo3_recipe/';
// DebuggerUtility::var_dump( self::JSON_URL );
// DebuggerUtility::var_dump( $jsonUri );
$response = $this->requestFactory->request(
$baseUri,
'GET'
);
if ( $response->getStatusCode() !== 200 ) {
throw new \RuntimeException(
'Returned status code is ' . $response->getStatusCode()
);
}
if ( $response->getHeaderLine( 'Content-Type' ) !== 'application/json' ) {
throw new \RuntimeException(
'The request did not return JSON data'
);
}
return $response->getBody()->getContents();
Get record storage page in Controller
$pidList = $this->configurationManager->getConfiguration( \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK )['persistence']['storagePid'];
get cObject in Controller
$contentObj = $this->configurationManager->getContentObject();
Environment Variables
$uploads_path = \TYPO3\CMS\Core\Core\Environment::getPublicPath() . $uploads_folder;
Flash Message
In Controller
$this->addFlashMessage( 'Only bibText-Files here please.', $messageTitle = '', $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, $storeInSession = TRUE );
Flash Message from other Queue/Plugin/Controller
Extbase FE
$queue = $this->controllerContext->getFlashMessageQueue('extbase.flashmessages.tx_femanager_pi1');
$msg = $queue->getAllMessagesAndFlush();
if ($msg) {
$defaultQueue = $this->controllerContext->getFlashMessageQueue();
foreach ($msg as $m) {
$defaultQueue->enqueue($m);
}
}
Backend
$flashMessageService = $this->objectManager->get(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
$messageQueue = $flashMessageService->getMessageQueueByIdentifier();
$messageQueue->addMessage($message);
ODER (für Extbase Controller
$msg = $messageQueue->getAllMessagesAndFlush();
if ($msg) {
$defaultQueue = $this->controllerContext->getFlashMessageQueue();
foreach ($msg as $m) {
$defaultQueue->enqueue($m);
}
}
Clear Cahce command
TCEMAIN.clearCacheCmd = 123,456,789
Fluid inline
If
{f:if(condition: ValueNameHere, then: 'active')}
{f:if(condition: '{ValueNameHere} == \'Yes\'', then: 'active')}
{f:if(condition: '{ValueNameHere} == "Yes"', then: 'active')}
count
{objects -> f:count()}
For
<f:for each="{recipy.tags}" as="tag">{tag.tagkey}</f:for>
{tag.tagkey -> f:for(each:'{recipy.tags}',as:'tag')}
Hack (for additional text before/after the variable:
{f:if(condition: i.isLast, then: 'data-{tag.tagkey}="1" ', else: 'data-{tag.tagkey}="1" ') -> f:for(each:'{recipy.tags}',as:'tag')}
Syntax Example inline in non-inline
<f:link.action class="ajaxLink" action="show" pageUid="10" arguments="{xugeo:xugeo,selimage:oneImage}"
additionalAttributes="{ data-showuri:' {f:uri.action( action:\'show\', arguments:{xugeo:xugeo,selimage:oneImage} )} ' }" >
Fluid link pass on date formated as
additionalParams needs array notation from T3 9 onwards? (wrong examples in T3 docs)
Does not work nested (format in additionalParams part), so variable view helper is needed.
<f:variable name="eventDate">{event.date -> f:format.date(format:'U')}</f:variable>
<f:link.page pageUid="{settings.formPageUid}" additionalParams="{'tx_powermail_pi1[veranstaltung]':'{eventDate}' }"> Anmelden für diesen Termin!</f:link.page>
Typoscript - get Content Elements based on date field
Content elments only in the future and X days old
variables {
content < styles.content.get
..
page.10.variables.content.select.where = {#colPos}=0 AND ( {#date} > (UNIX_TIMESTAMP() - (60*60*24* {$plugin.ebersbergmuseumconfig.keepActualForDays} )) OR {#date} = 0)
Powermail: select list based on own table, only in the futurer (events registration)
lib.powermailEventOptions = CONTENT
lib.powermailEventOptions {
table = tx_ebersbergevents_domain_model_event
select.pidInList = 22
select.orderBy = date desc
select.where = ( {#date} > (UNIX_TIMESTAMP() - (60*60*24)) OR {#date} = 0)
AJAX plugin and call
Configuration/TCA/Overrides/tt_content.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Extension',
'GetFilteredTicketsAjax',
'AJAX plugin for getting Tasks on the fly'
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Extension',
'Setfavoritesajax',
'AJAX plugin for setting favorites for users'
);
ext_localconf.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Extension',
'GetFilteredTicketsAjax',
[
\Vendor\Extension\Controller\TicketController::class => 'getFilteredTickets, new, newForProject, edit, create, update',
],
// non-cacheable actions
[
\Vendor\Extension\Controller\TicketController::class => 'getFilteredTickets, new, newForProject, edit, create, update',
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Extension',
'Setfavoritesajax',
[
\Vendor\Extension\Controller\TicketController::class => 'setfavorites, index, list, noAccess, show, new, newForProject, create, edit, update, delete',
],
// non-cacheable actions
[
\Vendor\Extension\Controller\TicketController::class => 'setfavorites',
]
);
/home/oe/Work/Vorlagen/extension/Configuration/TypoScript/constants.typoscript
plugin.tx_extension_getfilteredticketsajax {
view {
templateRootPath = EXT:extension/Resources/Private/Templates/
partialRootPath = EXT:extension/Resources/Private/Partials/
layoutRootPath = EXT:extension/Resources/Private/Layouts/
}
persistence {
storagePid = XX, YY
}
}
plugin.tx_extension_setfavoritesajax {
view {
# cat=plugin.tx_extension_setfavoritesajax/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:extension/Resources/Private/Templates/
# cat=plugin.tx_extension_setfavoritesajax/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:extension/Resources/Private/Partials/
# cat=plugin.tx_extension_setfavoritesajax/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:extension/Resources/Private/Layouts/
}
persistence {
# cat=plugin.tx_extension_setfavoritesajax//a; type=string; label=Default storage PID
storagePid = XX, YY
}
}
/home/oe/Work/Vorlagen/extension/Configuration/TypoScript/setup.typoscript
plugin.tx_extension_getfilteredticketsajax {
view {
templateRootPaths.0 = EXT:extension/Resources/Private/Templates/
templateRootPaths.1 = {$plugin.tx_extension_setlayoutsettingsajax.view.templateRootPath}
partialRootPaths.0 = EXT:extension/Resources/Private/Partials/
partialRootPaths.1 = {$plugin.tx_extension_setlayoutsettingsajax.view.partialRootPath}
layoutRootPaths.0 = EXT:extension/Resources/Private/Layouts/
layoutRootPaths.1 = {$plugin.tx_extension_setlayoutsettingsajax.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_extension_getfilteredticketsajax.persistence.storagePid}
#recursive = 1
}
features {
#skipDefaultArguments = 1
# if set to 1, the enable fields are ignored in BE context
ignoreAllEnableFieldsInBe = 0
}
mvc {
#callDefaultActionIfActionCantBeResolved = 1
}
}
plugin.tx_extension_setfavoritesajax {
view {
templateRootPaths.0 = EXT:extension/Resources/Private/Templates/
templateRootPaths.1 = {$plugin.tx_extension_setfavoritesajax.view.templateRootPath}
partialRootPaths.0 = EXT:extension/Resources/Private/Partials/
partialRootPaths.1 = {$plugin.tx_extension_setfavoritesajax.view.partialRootPath}
layoutRootPaths.0 = EXT:extension/Resources/Private/Layouts/
layoutRootPaths.1 = {$plugin.tx_extension_setfavoritesajax.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_extension_setfavoritesajax.persistence.storagePid}
#recursive = 1
}
features {
#skipDefaultArguments = 1
# if set to 1, the enable fields are ignored in BE context
ignoreAllEnableFieldsInBe = 0
}
mvc {
#callDefaultActionIfActionCantBeResolved = 1
}
}
types.1617455215 = layoutajax
layoutajax = PAGE
layoutajax < ajax
layoutajax {
typeNum = 1617455215
10.pluginName = Setlayoutsettingsajax
}
filteredticketajax = PAGE
filteredticketajax < ajax
filteredticketajax {
typeNum = 1617455216
10.pluginName = GetFilteredTicketsAjax
}
types.1617455214 = ajax
ajax = PAGE
ajax {
typeNum = 1617455214
config {
disableAllHeaderCode = 1
# additionalHeaders.10.header = Content-type:application/json
admPanel = 0
debug = 0
}
# Prevent caching if necessary
#10 = COA_INT
#10 < plugin.tx_extension_setfavoritesajax
10 = USER
10.userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
10.extensionName= Extension
10.pluginName = Setfavoritesajax
10.vendorName = Vendor
}
JS
$(".mtTriggerTickets").on("click", function (event, data) {
// data all lowercase!!
let id = $(this).data("mtproject");
//console.log($(this).attr('aria-expanded'));
if ($(this).attr('aria-expanded') != 'false') {
// clear and show spinner
$('.oespinner').css('display','block');
$("#ticketsContentAjax").html('');
console.log("#ticketsForProject" + id);
// ######### 1) direct show (pre-loaded version) ########
//console.log("clicked: " + id);
let content = $("#ticketsForProject" + id).html();
$("#ticketsContent").html(content);
$('#ticketsContent').find('[data-bs-toggle="tooltip"]').tooltip();
// ######### 2) Future (ajax load version) ########
console.log("ajax: get tickets for project # " + id );
$.ajax({
url : '/filteredticketajax?type=1617455216',
type : 'POST',
data : {
'tx_extension_getfilteredticketsajax[project]' : id,
'tx_extension_getfilteredticketsajax[dateFrom]' : $("#dateFrom").val(),
'tx_extension_getfilteredticketsajax[dateTo]' : $("#dateTo").val()
},
dataType:'html',
success : function(data) {
//alert('Data: '+data['project']);
console.log(data);
$("#ticketsContentAjax").html(data);
$('#ticketsContentAjax').find('[data-bs-toggle="tooltip"]').tooltip();
$('.oespinner').css('display','none');
},
error : function(request,error)
{
console.log(error);
console.log(JSON.stringify(request));
$("#ticketsContentAjax").html("<h3>Fehler</h3>Fehler beim Holen der Aufgaben.<br/>Eingeloggt?");
}
});
} else {
//$("#ticketsContent").html("");
}
});