Multiple Plugins in TYPO3 Extension - typo3

I try to create an TYPO3 extension with multiple Plugins in TYPO3 8.7 using EXTBASE (With and without Extensionbuilder).
I don't understand why, but the following TypoScript doesn't work:
(Error no Template found...)
plugin.tx_test_pi1 {
view {
templateRootPaths.0 = EXT:test/Resources/Private/Templates/
...
}
plugin.tx_test_pi2 {
view {
templateRootPaths.0 = EXT:test/Resources/Private/Templates/
}
However, if I made the following changes all PlugIn's will work:
plugin.tx_test {
view {
templateRootPaths.0 = EXT:test/Resources/Private/Templates/
}
What I'm missing?

Extbase uses the general TypoScript configuration. The plugins are not separated any more by classes. You can use three plugins and only one controller.
Maybe have a look at this page: https://docs.typo3.org/typo3cms/ExtbaseFluidBook/4-FirstExtension/7-configuring-the-plugin.html

Related

Add templateLayout option to tx_news sepecific to view type?

Using PageTSConfig I want to add some template options to the tx_news plugin.
How do I make it so that List template options are only shown when list view is active, and the same for Detail template options?
I thought it would be something like this:
tx_news.templateLayouts {
types {
list {
1 = Alt List
}
detail {
2 = Alt Detail
}
}
}
By PageTS it's only possible to handle different list templates, the code must look like this:
tx_news.templateLayouts {
1 = A custom layout
99 = LLL:fileadmin/somelocallang/locallang.xlf:someTranslation
}
For different detail views you need to use TypoScript settings options.
All examples you can see here:
https://docs.typo3.org/p/georgringer/news/main/en-us/Tutorials/Templates/TemplateSelector/Index.html

Define TYPO3 content element layouts for a specific list_type

In TYPO3 you can define custom Layouts to show up exclusively at
Appearance > Content Element Layout > Layout
for a specific CType like e.g. “gridelements_pi1”. How can i do this for specific list_type (where CType is “list”)?
code example:
TCEFORM {
tt_content {
layout {
addItems {
# layout items for all
}
types {
# CType "gridelements_pi1"
gridelements_pi1 {
addItems {
# layout items only for "gridelements"
}
}
list {
# is it possible to have
# layout items only for list_type "XYZ" ?
}
}
}
}
}
AFAIK it is not possible to limit this to a specific list_type.
CType = End of story (like in your example)
Possible solution: if this is your own extension, you can add your own unique CType instead of just calling it "list".
tt_content_defValues {
CType = your_own_ctype
list_type = extname_pluginname
}
As Mikel already said: there are no more options in the typoscript structure to configure special plugins.
But it might be possible to use conditions which are possible in TSconfig to identify the plugin type in the current context.
I remember an installation where it was used, but I don't remember the exact configuration and whether this still works in newer TYPO3 versions. So unfortunately I have no working example or documentation for this case.
This works
TCEFORM{
tt_content{
layout {
types {
div {
addItems {
30 = Grey
}
}
}
}
}

Override a Fluid Template from another extension

I'm working on a TYPO3 webpage for a magazine. Therefore I'm using the extension "news" or "tx_news".
Everything works fine, except that I'm confused how and where to override the given fluidtemplates from the news extension. For the webpage I'm using an own extension to keep all the backend layouts and fluid templates stored, I would like to include an own fluidtemplate for the News as well inside my extension, so the changes I make won't get overriden when I update the news extension of course.
I've tried just copy pasting the fluid templates from the news into my extension with the hope that they get overriden, since my extension has the highest priority in the backend. Also I found on the documentation that I should add the following lines into my TS setup:
plugin.tx_news {
view {
templateRootPaths >
templateRootPaths {
0 = EXT:news/Resources/Private/Templates/
1 = fileadmin/templates/ext/news/Templates/
}
partialRootPaths >
partialRootPaths {
0 = EXT:news/Resources/Private/Partials/
1 = fileadmin/templates/ext/news/Partials/
}
layoutRootPaths >
layoutRootPaths {
0 = EXT:news/Resources/Private/Layouts/
1 = fileadmin/templates/ext/news/Layouts/
}
}
}
I have added those lines at the bottom in the setup.txt of my own extension with customized paths of course and it didn't work either.
I appreciate all the help.
You missed to declare the pathes to your version of the templates.
you have two ways:
use the constants ext:news provides you and inserts automatically in the TS setup
add some lines direct to the plugin configuration.
As you use an page extension for all configuration you would avoid the TS constant editor or use it only to identify the names of the constants.
// Path constants from ext:news:
plugin.tx_news {
view {
layoutRootPath = EXT:yourextension/Resources/Private/News/Layouts/
partialRootPath = EXT:yourextension/Resources/Private/News/Partials/
templateRootPath = EXT:yourextension/Resources/Private/News/Templates/
}
}
Anyway you should end up with a TS like this (inspect with TSOB):
plugin.tx_news {
view {
templateRootPaths {
0 = EXT:news/Resources/Private/Templates/
1 = EXT:yourextension/Resources/Private/News/Templates/
}
partialRootPaths {
0 = EXT:news/Resources/Private/Partials/
1 = EXT:yourextension/Resources/Private/News/Partials/
}
layoutRootPaths {
0 = EXT:news/Resources/Private/Layouts/
1 = EXT:yourextension/Resources/Private/News/Layouts/
}
}
}
If you use method 2 you could use higher values to give your templates higher priority - in case multiple extensions and template replacements are active.
This configures the pathes for the layouts, partials and templates you are overriding:
Resources
+- Private
+- News
+- Layouts
+- Partials
+- Templates
in your extension.
Don't use the TS from your question (even if it comes from the original manual.)
It deletes the predefined pathes. (Lines 3,8,13). This might fail after an update where the internal pathes have changed.
Copy only templates from EXT:news in your extension which you
want to change. Your example TypoScript works as fallback and templates missed in 1 are searched in 0.
Overwrite only TypoScript that you want to change.
Then use TypoScript Object Browser and check the TypoScript setup for
plugin.tx_news.view...
If you don't see right paths the order of TypoScript loading must be
changed.

TYPO3 - fluidstyledcontent wrap element

I would like to add a custom class to the wrap of the whole output of a custom plugin. fluid_styled_content generates the <div id="c55"> tag. There I would like to add the custom class defined in the flexform of the plugin.
Do I have to override the file HeaderContentFooter.html of the fluid_styled_content package or is there a different solution for that problem. If I override that file I can't access the flexform values of the plugin.
I'm thankful for every help.
Cheers
To copy the layout to your own template folder, this is the best approach to solve this :
I am not sure, why you can't access to the plugin settings.
Create a template extension (sitepackage):
copy the file
typo3conf/ext/sitepackage/Resources/Private/Fluid/Content/Layouts/HeaderContentFooter.html
add this to TypoScript:
plugin.tx_sitepackage {
view {
templateRootPaths.0 = EXT:sitepackage/Resources/Private/Templates/
partialRootPaths.0 = EXT:sitepackage/Resources/Private/Partials/
layoutRootPaths.0 = EXT:sitepackage/Resources/Private/Layouts/
}
}
add something like this to HeaderContentFooter.html
{namespace css=Vendor\Sitepackage\ViewHelpers}
and to render the CSS class
{css:getclass()}
Create a Viewhelper in
sitepackage/Classes/ViewHelpers/getclass.php
with something like this inside:
namespace Vendor\Sitepackage\viewhelper ;
class getclassViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
public function render() {
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
$settings = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT );
return $settings['FlexFormfieldName'] ;
}
}
Not tested Completely but should do so

Configuring Single RTE Wrapper for Multiple Classes - Typoscript/Typo3

I'm trying to write Typoscript that will configure the Typo3 Rich Text Editor to wrap a given element with more than one class.
In the project's TsConfig/Page/rte.txt file, I have:
RTE {
classes {
button {
name = Button
}
}
However, I'd like to create a wrapper that would give the element more than just a single class. The below code doesn't work, but illustrates what I'm trying to accomplish:
RTE {
classes {
button {
name = Button
}
button danger {
name = Dangerous Button
}
}
According to this article, this doesn't seem to be possible, but I thought I'd ask and see if someone out there got crafty with their Typoscript and was able to accomplish this.
I tried everything to handle styles for tables that way, but there is currently no way to handle more than one CSS-Class for a RTE style definition.
The only way to handle this, is creating new CSS classes and extend the available button styles via LESS or SCSS.
In TYPO3 7 you can use this following RTE configuration to use multiple classes. The magic happens in the class-definition with the attribute "required"
RTE {
default {
proc.allowedClasses := addToList(btn-dark)
buttons.link.properties.class.allowedClasses := addToList(btn-dark)
}
classes.btn-dark {
name = Dark-Button
requires = btn btn-small
}
classesAnchor.buttonDark {
class = btn-dark
type = page
}
}