Nested contentElement by another FLUIDTEMPLATE in own extension - typo3

I want to write an extension that wrap a tag container around every type of contentElement in frontend. For instance <div>...</div>.
I could override the layout and template paths of fluid_styled_content and code my own html. But, what if another extension overrides my paths and use its own.
I would like to respect the recodings of those other extensions and wrap this just the same. I want to KEEP the changes the other extension did and wrap my own code additionally around.
At the moment I do this in typoscript:
lib.contentElement.stdWrap.wrap = <div>|</div>
...which works well. But that should not be the way in the age of FLUIDTEMPLATE.
What can I do?
Thanks a lot.

Related

Condition for backend layout name in Typo3 10+

I'm looking for a way to render a partial for when an element is placed it on a part of the backend layout and another partial for when the same element is placed it on another part of the backend layout.
My backend layout names are "Header" on top and "Normal" on the bottom. I want to render text-media element with one partial for when is on Header and another partial for when is on Normal.
For what I could find online seems that this must be done with typoscript. Particualrly I want to use typoscript condition because is the one that make more sense on my head.
I'm aware of this but the answers are not helping me at all.
This is the one that looks like something I could use.
[page["backend_layout"] == 'pagets__2']
page.bodyTagCObject.value.wrap = <body id="uid|" class="fullpage">
[end]
Any help is welcome even tutorials because clearly I have much to learn about typoscripting
You can pass the needed value as a variable to your FLUIDTEMPLATE-object.
The current backend-layout is available as pagelayout (Already with the 'backend_layout_next_level' taken into account).
page.10 = FLUIDTEMPLATE
page.10 {
variables {
pagelayout = TEXT
pagelayout.data = pagelayout
}
}
Solved it.
I have been able to solve this problem without useing Typoscript. (so I will keep ignoring typoscript :D )
Dropping the variables of the loaded templates (not partials) made me realized that there was a property holding the colPos of the backend layout so all I had to do was an if condition on the textmedia default template.
<f:if condition="{data.colPos} == 1">
If the colPos of the backend layout is 1 print something
</f:if>

Wrap H1-H6 Tags with Typo3 ParseFunc depending on the class set in RTE

I want to add inline-svgs to my h1 to h6 Tags depending on the class set in the RTE.
Example:
RTE:
<h1 class="icon--clock">Header</h1>
Output:
<h1 class="icon--clock"><svg>...</svg>Header</h1>
I've done something similar with links before, using the parseFunc Config. A method like this: https://wiki.typo3.org/External_links
Is there any way to access and split the tag and class like the link parameters through TypoScript?
I also tried using a userFunc
lib.parseFunc.userFunc = ...\MyClass->MyUserFunc
but in Params I only get the tag content, not the tag or the classes that have been set themselves.
I'm using Typo8 with the ckeditor, but I don't think that makes a difference.
Can I even do this?
How do I do this?
I know that I can alternatively add different header layouts and use the tt_content header field, because it's easier to manipulate the template there. But I'd love to know if there is a way to this in the RTE.
I think you could do it in typoscript, but that would be very complicated as you need to analyze the attributes of the Hn-tags.
A simpler method which came to mind would be: use CSS and ::before. So you can use a selector to the class to insert the matching SVG.
This also can be done with javascript but as CSS can do it it would be more efficient to use CSS.

Can i add more colors in tx_gridelements

i want to add more backend colors in Typo3 Gridelements.
Under Typo3 -> List -> CE Backend Layout is an Option "Frame" with 4 colors and i want to add more colors.
Is there a way for it?
Best Regards
You probably want to use something like this in your pageTS:
TCEFORM.tx_gridelements_backend_layout{
frame{
addItems{
10 = unicorn-pink
}
}
}
You can change every field from every table with this method.
See https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/TCEform/Index.html for further information about this.
Just adding the value in TCEFORM might not be enough, since you will need to add CSS to get the colors assigned to those new classes.
So you will at least need to have a small extension providing the items, a basic folder structure as in the usual sitepackages and the CSS embedded via ext_tables.php and/or ext_localconf.php

Switch Locales in TYPO3, "live", on one page

On Set multiple locales on one page I was enlightened you can switch locales in php live, during one php call.
For example, like this:
$locale_old = setlocale(LC_TIME, 0);
setlocale(LC_TIME, 'fr_CH');
// do something
setlocale(LC_TIME, $locale_old);
What about TYPO3? I have different dates on one page that should be displayed in different languages according to the content element they're in.
As the locale that renders the date is set globally, it can't be done using these two TypoScript Settings:
config.locale_all = de_CH
config.locale_all = fr_CH
Is it possible at all - and how?
This is not possible with TypoScript, because TypoScript is not executed line by line, but rather parsed into one configuration tree which is then passed to the FrontendController (technical the call order is the other way around, but do not try to get into the inner magics of TYPO3 here).
So you either need to define your own wrapper script that you can call at the needed places with stdWrap methods or you switch to Fluid templating and create a viewhelper that does the switching for you. Inside this viewhelper you can use code you mentioned in your question.
The TypoScript setting does the setlocale() globally. Of course you can switch it while you execute your own PHP code. That means you can switch the setting (even in the FrontendController) inside your Controller or in your View.

tx_news Paginate with dynamic variables

I have created a custom template for paginations. But I want to display a count of all news articels and so I'm looking for a solution to pass a variables to the pagination. I don't want to build a custom viewhelper, I want to stick with the original PagionationViewhelper.
Maybe have anyone a idea?
Make the counting with a cObject like lib.newscount
then you pass that with the cObject Viewhelper like:
<f:cObject typoscriptObjectPath="lib.newscount"></f:cObject>