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
Related
Is there some chance to simple update _viewContainer??
I am trying create directive for material-button component, that add hidden classic button for submit form by hit enter key. I need to add simple html to _viewContainer, something like this
import 'package:angular/angular.dart';
#Directive(
selector: '[kpMaterialSubmit]',
)
class KpMaterialSubmit {
final TemplateRef _templateRef;
final ViewContainerRef _viewContainer;
KpMaterialSubmit(this._viewContainer, this._templateRef);
#Input()
set kpMaterialSubmit(bool showButton) {
_viewContainer.clear();
if (showButton) {
_viewContainer.createEmbeddedView(_templateRef);
//THIS IS THE IMPORTANT PART
_viewContainer.createMyCustomView('<button class="hidden">Submit</button>');
} else {
_viewContainer.createEmbeddedView(_templateRef);
}
}
}
I have done something similar and it works. I don't know if there is a better way.
Instead of using html text directly, create a component.
Add the import to the component template:
import 'package:<your package>/<path to component>/<component source name>.template.dart';
Then add the component with the createComponent() method (instead of createMyCustomView()):
_viewContainer.createComponent(<componentName>NgFactory);
That's all!
If you need to style the component or add any attribute you can get the reference and derive the HtmlElement instance:
ComponentRef _componentRef = _viewContainer.createComponent(<componentName>NgFactory);
HtmlElement element = _componentRef.location;
element.style.background = 'green';
element.setAttribute('value', 'text');
I need to get the value of the field backend_layout in my fluid content element.
Via <f:debug /> I get the value in my page template, but not at the level of the content element.
try to set the following in setup typoscript for "page":
page {
# e.g. inside your page template "10"
10 = FLUIDTEMPLATE
10 {
# ...
variables {
# access this with {layout} in your fluid templates
layout = TEXT
layout {
data = levelfield:-2,backend_layout_next_level,slide
override {
field = backend_layout
}
}
}
}
}
The easiest way is to use the vhs extension and the view helper v:page.info available there or pass the variable somehow (TypoScript, register, etc.) down to your content elements.
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
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
}
}
Ive done some search but no success.. i am trying to figure out how to define others layout() parts such layout()->content variable.. i would love to get int layout()->navigation (a custom one) which display the navigation..
Any ideas ?
Thanks.
Not sure if this is what you want, but you can create additional 'parts' of layout simply by assigning a value to your new part. ZF will take care of the rest. For example, in a bootstrap.php you could do:
public function _initNewLayoutPart() {
$view = $this->bootstrap('view')->getResource('view');
$view->layout()->newpart = 'some new part';
}
Then in your layout.phtml you could just echo the new part:
<?php echo $this->layout()->newpart; ?>
It is possible by just creating a new variable in layout, you can define it in your controller (preferably in init or postDispatch). Just like this:
public function init()
{
$this->view->layout()->motd = '<b>Message of the day.</b>';
}
Then in your actual view where you want to see the message, all you have to do is:
<?php echo $this->layout()->motd; ?>
If you want something fancier, such as rendering a whole page or sidebar, try the following:
public function init()
{
$this->view->layout()->sidebar = $this->view->action('render', 'sidebar');
}
With render being the action (including render.phtml) and sidebar being the controller.