Get FlexForm configuration in TypoScript - typo3

I need to get the page.headerData in typoscript from pi_flexform.How can implement my requirement?
page = PAGE
page {
headerData {
10 = TEXT
10.value =<script>/**********************/</script>
}
}

I am not so sure about what you really need. I am guessing you want to access a FlexForm configuration inside your TypoScript?
Since the version 8.4 this is possible by using plain TypoScript
lib.flexformContent = CONTENT
lib.flexformContent {
table = tt_content
select {
pidInList = this
}
renderObj = COA
renderObj {
10 = TEXT
10 {
data = flexform: pi_flexform:settings.categories
}
}
}
The key flexform is followed by the field which holds the flexform data and the name of the property whose content should be retrieved.
Before 8.4 you need to use a userFunc and retrieve the value by using PHP
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
$flexFormKey = str_replace('.', '|', $keyParts[1]);
$settings = $flexFormService->convertFlexFormContentToArray($flexFormContent);

Related

TYPO3: clear cache by tag for custom content element when record in backend is changed

I have a sysfolder with records which get displayed in the frontend via a custom content element.
Now I have the problem that the frontend is not updated when a new record is added or an existing record is changed.
To clear the cache I'm using a hook in ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['foobar'] =
\Vendor\Name\Hooks\DataHandler::class . '->clearCachePostProc';
The hook looks like this:
<?php
namespace Vendor\Name\Hooks;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class DataHandler implements SingletonInterface
{
public function clearCachePostProc(array $params): void
{
if (isset($params['table']) && $params['table'] === 'tx_foo_domain_model_bar') {
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$cacheManager->flushCachesByTag('1642782027');
}
}
}
And the content element is implemented with FLUIDTEMPLATE and a dataprocessor:
tt_content {
foo_bar =< lib.contentElement
foo_bar {
templateName = myTemplate
stdWrap.cache {
key = tx_foo_domain_model_bar
tags = 1642782027
lifetime = default
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tx_foo_domain_model_bar
pidInList = {$foo.storage_pid}
as = foobar
}
}
}
}
Everything seems to work but when I hit Cmd+R/Ctrl+R and reload the page or visit it again via the navigation, the page is not updated with the latest content.
I implemented the following solution.
Within the Typoscript Setup add a addPageCacheTag to your custom content element:
tt_content {
foo_bar =< lib.contentElement
foo_bar {
templateName = FooBar
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tx_foo_domain_model_bar
pidInList = {$foo.storage_pid}
as = foobar
}
}
stdWrap.addPageCacheTags = foo_bar
}
}
Add the clearCacheCmd to the Page TSConfig from the storage page like:
TCEMAIN.clearCacheCmd = cacheTag:foo_bar
For testing, add this to your Fluid-Template and be sure to test with a separate browser (without BE login):
<div style="color: red;"><f:format.date format="d.m.Y - H:i:s">now</f:format.date></div>
Kudos to https://daniel-siepmann.de/posts/2019/typo3-content-caching.html
You could use the EXT:Fluid Page Cache
https://extensions.typo3.org/extension/fluid_page_cache
This EXT does all the things you need automatically.

Typo3 10.4.4 Gridelements 10.0.0 extension not working

Hey I am pretty new to typo3 and I want to build a website.
I am running version 10.4.4 of TYPO3 with the bootstrap package installed.
I have tried to follow the guide on https://docs.typo3.org/typo3cms/extensions/gridelements/stable/
I have copied the TypoScript into my template setup, but there is no output on the frontend.
Remember I am new to this so I don't understand the TypoScript well yet.
So any ideas to what I could do?
EDIT:
I want to use GriElements so that I can create my own layouts on my page. The standard layouts are good but I need more freedom than what they offer.
I can get output on the frontend without GridElements, but when I use the extension only the content in the GridElements block wont show. If I remove the standard TypoScript from the example on the manual page for this extension i get an error saying "Oops an error occurred! Code:" and then a code that changes every time I update the page.
My TypoScript on my template looks like this:
page.includeCSS.1 = fileadmin/user_upload/template/css/fonts.css
page.includeCSS.theme = fileadmin/user_upload/template/css/custom-theme.scss
# plugin.tx_bootstrappackage._LOCAL_LANG.da.readmore = test (NOT WORKING)
# https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ApiOverview/Internationalization/ManagingTranslations.html
page.meta.robots = noindex, nofollow
page.meta.robots.replace = 1
page.10.partialRootPaths.3 = fileadmin/user_upload/template/partials/ContentElements/
page.10.partialRootPaths.4 = fileadmin/user_upload/template/Partials/Page/
page.10.dataProcessing.10.levels = 3
page.includeJSFooterlibs.bootstrap_navbar = fileadmin/user_upload/template/js
page.includeJSFooterlibs.bootstrap_navbar = fileadmin/user_upload/template/js/navbar.js
lib.contentElement.partialRootPaths.20 = fileadmin/user_upload/template/partials/ContentElements/
lib.contentElement.partialRootPaths.20 = fileadmin/user_upload/template/Partials/ContentElements/
lib.gridelements.defaultGridSetup {
// stdWrap functions being applied to each element
columns {
default {
renderObj = COA
renderObj {
# You can use registers to i.e. provide different image settings for each column
# 10 = LOAD_REGISTER
20 =< tt_content
# And you can reset the register later on
# 30 = RESTORE_REGISTER
}
}
}
# if you want to provide your own templating, just insert a cObject here
# this will prevent the collected content from being rendered directly
# i.e. cObject = TEMPLATE or cObject = FLUIDTEMPLATE will be available from the core
# the content will be available via fieldnames like
# tx_gridelements_view_columns (an array containing each column)
# or tx_gridelements_view_children (an array containing each child)
# tx_gridelements_view_column_123 (123 is the number of the column)
# or tx_gridelements_view_child_123 (123 is the UID of the child)
}
lib.tt_content.shortcut.pages = COA
lib.tt_content.shortcut.pages {
10 = USER
10 {
userFunc = tx_gridelements_view->user_getTreeList
}
20 = CONTENT
20 {
table = tt_content
select {
pidInList.data = register:pidInList
where = colPos >= 0
orderBy = colPos,sorting
orderBy.dataWrap = FIND_IN_SET(pid,'{register:pidInList}'),|
}
}
}
tt_content.shortcut.5 = LOAD_REGISTER
tt_content.shortcut.5 {
tt_content_shortcut_recursive.field = recursive
}
tt_content.shortcut.20 {
0 {
tables := addToList(pages)
conf.pages < lib.tt_content.shortcut.pages
}
1 {
tables := addToList(pages)
conf.pages < lib.tt_content.shortcut.pages
}
}
tt_content.gridelements_pi1 >
tt_content.gridelements_pi1 = COA
tt_content.gridelements_pi1 {
#10 =< lib.stdheader
20 = COA
20 {
10 = USER
10 {
userFunc = tx_gridelements_view->main
setup {
default < lib.gridelements.defaultGridSetup
}
}
}
}
The statics i included is:
Bootstrap Package: Full Pacakage (bootstrap_package)
Bootstrap Package: Bootstrap 4.x (SCSS) (bootstrap_package)
XML Sitemap (seo)
Gridelements w/DataProssing (recommended) (gridelements)
Gallery (bm_image_gallery)
EDIT2:
New TypoScript with DataProcessing
lib.gridelements.defaultGridSetup =< lib.contentElement
lib.gridelements.defaultGridSetup {
templateName.field = tx_gridelements_backend_layout
templateName.ifEmpty = GridElement
layoutRootPaths {
1 = EXT:gridelements/Resources/Private/Layouts/
}
partialRootPaths {
1 = EXT:gridelements/Resources/Private/Partials/
}
templateRootPaths {
1 = EXT:gridelements/Resources/Private/Templates/
}
dataProcessing {
10 = GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor
10 {
default {
as = children
# Default options of the grid children processor
# Change them according to the needs of your layout
# Read more about it in the TypoScript section of the manual
# options {
# sortingDirection = ASC
# sortingField = sorting
# recursive = 0
# resolveFlexFormData = 1
# resolveBackendLayout = 1
# respectColumns = 1
# respectRows = 1
# }
}
}
}
}
My includes:
Fluid Contetn Elements (fluid_styled_content)
Fluid Contetn Elements CSS (fluid_styled_content)
Bootstrap Package: Full Pacakage (bootstrap_package)
Bootstrap Package: Bootstrap 4.x (SCSS) (bootstrap_package)
XML Sitemap (seo)
Gridelements w/DataProssing (recommended) (gridelements)
Gallery (bm_image_gallery)
The error I get:
Tried resolving a template file for controller action "Standard->3" in format ".html", but none of the paths contained the expected template file (Standard/3.html). The following paths were checked: /httpdocs/typo3conf/ext/bootstrap_package/Resources/Private/Templates/ContentElements/, /httpdocs/typo3conf/ext/gridelements/Resources/Private/Templates/
You probably missed to include the static template of gridelemnts. To do so edit your TS-Root-Template, select in the dropdown at the top "Info/Modify", hit the button "Edit the whole template record", go to tab "Includes" and select gridelements static setup in the Multiselect box on the right.
Please provide more information:
Which static templates have you included at all? Maybe you forgot to include fluid_styled_content?
How does your Typoscript/Flexform setup look like?
For what do you need gridelements?
EDIT: bootstrap_package did not very well together with gridelements in the past. Maybe you should first try to install Benjamin Knott's extension autogrids (see this issue on github for more information)
EDIT 2: Try this Typoscript, it just wraps a section around all elements but maybe you will then see your content in the frontend:
tt_content.gridelements_pi1.20.10.setup {
section < lib.gridelements.defaultGridSetup
section {
wrap >
dataWrap = <section id="c{field:uid}">|</section>
}
}
SOLVED:
I installed an extension that is called "Grids for bootstrap" included it in the template and it worked.
Thnaks for all the help you guys gave!
I think your problem is coming from your fluid code for gridelemnts, you didn't use the right syntax maybe.

get all checked checkbox values from a powermail field in typoscript

I’m looking for a way to get all checked checkbox-values from a field in a powermail form. I can access single values from the array in my typoscript template with
data = GP:tx_powermail_pi1|field|marker|index.
Is there a way to interate over the array when I don't know the number of checkboxes (dynamically filled) or to serialize the array? I am not experienced with typoscript or powermail but allready tried to find a solution for quite some time.
What i am trying to achieve ist to have a multiselect field for people to send the mail to that gets populated from fe_users.
The relevant code from the typoscript template that overwrites the receiver is:
plugin.tx_powermail {
settings {
setup {
receiver {
enable = {$plugin.tx_powermail.settings.receiver.enable}
overwrite {
email = COA
email {
10 = CONTENT
10 {
table = fe_users
select {
pidInList = 8689
where {
# UID of the fe_users record is given in field with marker {fragegehtan}
data = GP:tx_powermail_pi1|field|fragegehtan|0
wrap = uid=|
intval = 1
}
}
renderObj = COA
renderObj {
10 = TEXT
10.field = email
stdWrap.wrap = |,
}
}
}
}
}
}
}
}
This is supposed to create a comma separated list of uids of all selected fe_users. Ist there any advice how to do it?

Pass Fluid variable to TypoScript

I want to pass a variable (uid of category) in Fluid to a TypoScript :
<f:cObject typoscriptObjectPath="lib.testFluid" data="{setting.myvar}/>
Then i want to use the var to get all content elements in folder with pid 942 and the category {setting.myvar}
lib.testFluid = COA
lib.testFluid = CONTENT
lib.testFluid {
table = tt_content
select {
pidInList = 942
where = selected_categories = |
}
}
This does not work, it creates an MySql syntax error. I also tried using current = 1 instead of the where clause without success. I looked at post TYPO3: pass variable to typoscript via cObject? and I can recreate it but it does not work with my script. (TYPO3 8)
If i use
...
where = selected_categories = 13
....
the scrip will succesfully display all CE with category 13. How do i make it work with a var?
could you try this:
<f:cObject typoscriptObjectPath="lib.testFluid" data="{myvar: setting.myvar}/>
lib.testFluid = CONTENT
lib.testFluid {
table = tt_content
select {
pidInList = 942
where.data = field:myvar
where.intval = 1
where.wrap = selected_categories=|
}
}
hard to test for me but it might work ...
I had to solve it once with markers. I couldn't find another simpler way. I give you a very general solution which you may adapt to your needs. For example you could set the pid value via a typoscript setting which is more elegant than to put it in the snippet code. Please try:
<f:cObject typoscriptObjectPath="lib.testFluid" data="{category: setting.myvar, catPid: 942}" currrentValueKey="category" />
The related TypoScript snippet:
lib.testFluid = COA
lib.testFluid {
10 = LOAD_REGISTER
10 {
category.cObject = TEXT
category.cObject.value.current = 1
catPid.cObject = TEXT
catPid.cObject.value.dataWrap = { field: catPid }
}
20 = CONTENT
20 {
table = tt_content
select {
pidInList.cObject = TEXT
pidInList.cObject.dataWrap = {REGISTER:catPid}
where = selected_categories=###category###
markers {
category.data = REGISTER:category
}
}
}
30 = RESTORE_REGISTER
}

How link to URL of single news article via CONTENT object

I am using the typoscript below to display news content via a CONTENT object. Everything is working great except the link doesn't go to the page of the article. Is there a way to tell the typolink that this is a news article and that it should use the cached CoolURI link for it?
Also, the additionalParameter I'm trying to append to the querystring isn't appearing.
temp.MMtest = COA
temp.MMtest {
10 = CONTENT
10.table = tt_news
#10.select.pidInList = 170 # Uid of the sysfolder where News records are stored
10.select.pidInList = 18
10.select.recursive = 10
#10.select.where = uid=10 # Uid of an existing News record
10.select.andWhere = deleted=0 AND hidden=0
10.renderObj = COA
10.renderObj {
10 = TEXT
10.field = title
10.wrap = Title: |<br>
10.typolink.parameter.field=uid
typolink.parameter.dataWrap=|
#typolink.additionalParams.insertData=1
typolink.additionalParams.data=&my_extra_param=something
#if.isTrue.field=header
}
10.renderObj.20=IMAGE
10.renderObj.20{
wrap=|
# show it only if inserted
stdWrap.if.isTrue.field=image
stdWrap.typolink.parameter.field=uid
file.import=uploads/pics/
file.import.field=image
file.width=100
file.height=100
}
}
I do not know, which parameters you need, so in short:
10.typolink {
# you need a page to link too
parameter = PAGE_ID_OF_SINGLE_VIEW
# create an cacheable link, that does not depend on cooluri or realurl.
useCacheHash = 1
# add the additional params
additionalParams.wrap = &tx_ttnews[uid]=|
# data expects special commands
# "&my_extra_param=something" cannot work on .data
additionalParams.data = field:uid
}
If you need more then one additionalParams i would do it this way:
10.typolink {
parameter = PAGE_ID_OF_SINGLE_VIEW
useCacheHash = 1
# Create an Content Object Array
# so you can separat the different entries
# the cObject will return &tx_ttnews[uid]=123&what[ever]=hardcodedvalue
# additionalParams is filled with that string and added to the url
additionalParams.cObject = COA
additionalParams.cObject {
10 = TEXT
10.wrap = &tx_ttnews[uid]=|
10.field = uid
20 = TEXT
20.wrap = &what[ever]=|
20.value = hardcodedvalue
}
}
You do not need
10.select.andWhere = deleted=0 AND hidden=0
this is added automatically by the CONTENT Object.
Read more about typolink about COA and about stdWrap and its property data and finally have a look at getText.