Typo3 LTS9 Routing: ReUse config.YAML - yaml

What's the right way to reuse config.yaml for routing?
Situation:
I have a typo3 installation with different websites. The routing-config with more than 200 lines is saved in:
\typo3conf\sites\website1\config.yaml
What the right way to use this config.yaml with all other websites and only reconfig the differences in:
\typo3conf\sites\website2-100\config.yaml
With typoscript this where easy. Is there a way to use this:
1. <INCLUDE_TYPOSCRIPT: source="FILE:\typo3conf\sites\website1\config.yaml">
2. Overide differences like "rootPageID: 2" or delete configs with ">"

To elaborate Jonas' hint, here a more concrete example:
Site configuration for the single site which is similar to all other and thus should be as short as possible, stored in sites/mysite/config.yaml
rootPageId: 14523
base: 'https://www.mysite.mytld'
imports:
- { resource: "EXT:mysitepackage/Configuration/Sites/defaultSiteConf.yaml" }
Content of EXT:mysitepackage/Configuration/Sites/defaultSiteConf.yaml, the default config shared for basically all sites (although exceptions are possible).
imports:
- { resource: "EXT:mysitepackage/Configuration/Sites/errorHandling.yaml" }
- { resource: "EXT:mysitepackage/Configuration/Sites/language.yaml" }
- { resource: "EXT:mysitepackage/Configuration/Sites/route.pages.yaml" }
- { resource: "EXT:mysitepackage/Configuration/Sites/route.tt_news.yaml" }
Content of EXT:mysitepackage/Configuration/Sites/language.yaml, as an example that the default config can be split into multiple files to track changes more easily
languages:
- title: Deutsch
enabled: true
base: /
typo3Language: de
locale: de_DE.UTF-8
iso-639-1: de
navigationTitle: Deutsch
hreflang: de-DE
direction: ltr
flag: de
languageId: '0'
- title: English
enabled: true
base: /en/
typo3Language: default
locale: en_GB.UTF-8
iso-639-1: en
navigationTitle: English
hreflang: en-GB
direction: ltr
fallbackType: fallback
fallbacks: '0'
flag: gb
languageId: '1'

If you use TYPO3v9, you can use imports:.
Documentation:
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Yaml/Index.html
From TYPOv10 on they can be relative, too:
Changelog:
https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/10.1/Feature-88742-ImportYamlFilesRelativeToTheCurrentYamlFile.html

Related

TYPO3 CKE Editor allow data-attribute

I have added
- { name: "Data Test", element: "p", attributes: { 'data-test': "test" } }
to my yaml config. I can select data attribute (and see it correct) in editor code. But after saving content elment TYPO3 is also deleting data-tesst="test" from code.
How can I solve this?
Thanks for help!
Martin
buttons:
link:
relAttribute:
enabled: true
targetSelector:
disabled: false
properties:
class:
allowedClasses: 'button, button_hell'
title:
readOnly: false
imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }
editor:
config:
# css definitions for the editor
contentsCss: "EXT:mw_theme/Resources/Public/Css/rte.css"
# can be "default", but a custom stylesSet can be defined here, which fits TYPO3 best
format_tags: "p;h1;h2;h3;h4;h5;h6;pre;address"
stylesSet:
# custom block level style
- { name: "Button", element: "a", attributes: { 'class': "button" } }
- { name: "Test", element: "p", attributes: { 'data-test': "test" } }
toolbar:
- [ 'Format', 'Styles' ]
- [ 'Bold', 'Italic', 'Underline', 'Blockquote', 'Subscript', 'Superscript']
- [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', 'HorizontalRule' ]
- [ 'NumberedList', 'BulletedList']
- [ 'Link', 'Unlink', 'Anchor', 'Table', 'SpecialChar', 'CodeSnippet', 'Youtube' ]
- [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord' ]
- [ 'Undo', 'Redo', 'RemoveFormat', 'ShowBlocks' ]
- [ 'Source', 'Maximize', 'About']
removePlugins:
- image
extraPlugins:
- justify
justifyClasses:
- text-left
- text-center
- text-right
- text-justify
Allow tags
processing:
allowTags:
- dl
- dt
- dd
page ts:
RTE { default { preset = mw_theme } }`
To allow saving data attributes to db from RTE fields, you need to ensure that:
1) RTE (CKEditor) will not strip the attributes. This is configurable using extraAllowedContent. Below is an example how to allow id attributes additionally to the default rule which allows data attributes and classes.
editor:
config:
extraAllowedContent:
- "*(*)[data-*]"
- "*[id]"
If you only need to add data attributes, you don't need the configuration above and can relay on default configuration (from rte_ckeditor/Configuration/RTE/Editor/Base.yaml), as data attributes are allowed by default there.
To test this configuration part, go to your RTE, click on the "view source" button switch back and switch again and see if the attribute is gone.
If it's still there it means your RTE config allows it.
2) then you need to configure PHP side of things - data transformation which happens before data is saved to db. See manual chapter: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Rte/Transformations/Process.html#transformations-process
Below is an example (taken from RTE yaml preset) of allowing data-abc attribute in transformation (in addition to attributes which are allowed by default).
processing:
allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop, data-abc]
So in your case you were missing proper configuration on the transformation part.
This depends on a whole lot of factors and a whole lot of your other configuration, but you seem to be. One quite common way, which could work would be to define extraAllowedContent as an additional config setting in your yaml like:
editor:
config:
extraAllowedContent: '*(*)[data-*]'
Or if i understood the other line right, also allow dt/dd/dl:
editor:
config:
extraAllowedContent:
- '*(*)[data-*]'
- dd
- dl
- dt
If the latter is the case, perhaps EXT:rte_ckeditor_dl might be worth a look, in order to get buttons to create that list.
I found solution:
extraAllowedContent:
p[data-test];

xs-app.json/routes/0: Format validation failed (Route references unknown destination "service-destination")

trying to install the approuter currently, following this tutorial:
https://blogs.sap.com/2017/07/18/step-7-with-sap-s4hana-cloud-sdk-secure-your-application-on-sap-cloud-platform-cloudfoundry/
When pushing the approuter to CF, I get an destination error:
xs-app.json/routes/0: Format validation failed (Route references unknown destination "service-destination")
This is my manifest.yml:
---
applications:
- name: xyz
command: 'node approuter/approuter.js'
host: xyz-93deb1cd-7b72-4060-94e7-21342342
path: approuter
memory: 128M
buildpack: https://github.com/cloudfoundry/nodejs-buildpack
env:
TENANT_HOST_PATTERN: 'xyz(.*).cfapps.eu10.hana.ondemand.com'
destinations: "[{"name":"service-destination", "url": "https://gfuowbasdatq19agtuthorizations-srv.cfapps.eu10.hana.ondemand.com", "forwardAuthToken": true}]"
SAP_JWT_TRUST_ACL: '[{"clientid" : "*", "identityzone" : "*"}]'
services:
- my-xsuaa
- service-destination
This is my xs-app.json:
{
"routes": [{
"source": "/",
"target": "/",
"destination": "service-destination"
}]
}
Where is the application actually searching for this destination? I created it in my CF-account as well, pointing to my service-url.
In YAML (as well as many other markup languages, e.g. JSON) double quotes inside double quotes need to be escaped. (Cf. the YAML spec section 7.3.1 and this blog post)
So for you there are two options for your destinations variable:
1. Replacing all " inside with \" (relatively cumbersome, especially if you want to change the destinations in the future)
2. Use single quotes as boundaries. So the value of your destinations variable would look like this:
'[{"name":"service-destination", "url": "https://gfuowbasdatq19agtuthorizations-srv.cfapps.eu10.hana.ondemand.com", "forwardAuthToken": true}]'

Symfony 3 | JMSi18nRoutingBundle exclude SonataMediaBundle routes

Guys I use JMSi18nRoutingBundle with some JMS bundles too, so I wanted to exclude sonata media routes, so i tried : i18n = false
by this code
media:
resource: '#SonataMediaBundle/Resources/config/routing/media.xml'
prefix: /media
options: { i18n: false }
also i tried:
media:
resource: '#SonataMediaBundle/Resources/config/routing/media.xml'
prefix: /media
options:
i18n: false
but i still got the links like this:
http://mysite.local/app_dev.php/en/uploads/media/Slider/0001/03/405f4n41adb162399344690cf85143c52a0ed147.jpeg

TYPO3 CKeditor not rendering javascript link

I am using TYPO3 8.7.8 and have to provide a javascript link to deactivate Google Analytics.
The link should look like this:
Deactivate Google Analytics
Unfortunately the link doesn't appear in the frontend, that means it's just a normal text inside a <p> tag. However in the backend everything is fine and it shows up as a link there...
Here is my yaml-configuration for the CKeditor:
# Load default processing options
imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }
# Configuration for the editor
# For complete documentation see http://docs.ckeditor.com/#!/api/CKEDITOR.config
editor:
config:
allowedContent: true
linkJavaScriptLinksAllowed: true
contentsCss: ["EXT:rte_ckeditor/Resources/Public/Css/contents.css", "EXT:my_extension/Resources/Public/Stylesheets/styles.css", "EXT:my_extension/Resources/Public/Stylesheets/fonts.css"]
resize_enabled: true
stylesSet:
# block level styles
- { name: "Button Default", element: "a", attributes: { 'class': 'btn btn-default', 'role': 'button', 'aria-pressed': 'true'}}
format_tags: "p;h1;h2;h3;h4;h5;pre"
toolbarGroups:
- { name: styles, groups: [ styles, format ] }
- { name: basicstyles, groups: [ basicstyles ] }
- { name: paragraph, groups: [ list, indent, blocks, align ] }
- { name: links, groups: [ links ] }
- { name: clipboard, groups: [ clipboard, cleanup, undo ] }
- { name: editing, groups: [ spellchecker ] }
- { name: insert, groups: [ insert ] }
- { name: tools, groups: [ table, specialchar ] }
- { name: document, groups: [ mode ] }
justifyClasses:
- text-left
- text-center
- text-right
- text-justify
extraPlugins:
- justify
removePlugins:
- image
removeButtons:
- Anchor
- Underline
- Strike
buttons.:
link.:
queryParametersSelector.:
enabled: true
What am I missing here?
we just run into the same problem - we wrote a small linkhandler for typo3 allowing only the javascript:gaOptOut(); link.
Get it here:
https://www.infoworxx.de/download/ifx_linkhandler_googleAnalytics.zip
Sebastian
That is not a problem of ckeditor but is prohibited by TYPO3 itself to avoid security issues - XSS.
A solution I use is something like this TYPO3 force internal links to cross domain pages to use https in news so that an editor e.g. links to http://ga-output.tld and this will be replaced by the JS link.
You can add a class to your link in ckeditor using the source button (<>).
<a class="gaOptout" href="#">your linked text</a>
and now you just rewrite your function to an onclick event like this:
$('.gaOptout').on('click', function(){
your function
});
This still seems to be an issue in T3 9.5, especially with this Google OptOut Script.
Easy workaround without coding: we cut out the paragraph containing the javascript and put it in a separated html-element. Just cut it out from CKEs Source-view an paste it in a new element. To keep the article in sequence, just cut out the rest of the text an paste it in a new text-element.

How configure and use doctrine extension? (doctrine2-spatial)

I want use postrepgis in doctrine. I have find creof/doctrine2-spatial and I try use it. I have this error :
[Semantical Error] line 0, col 15 near 'ST_Contains(v.geopoint': Error: Class 'ST_Contains' is not defined.
I don't know why, I have read the documentation, I have try many differents configurations but alltimes same problem.
My config.yml
doctrine:
dbal:
driver: pdo_pgsql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
types:
geometry: CrEOF\Spatial\DBAL\Types\GeometryType
point: CrEOF\Spatial\DBAL\Types\Geometry\PointType
polygon: CrEOF\Spatial\DBAL\Types\Geometry\PolygonType
linestring: CrEOF\Spatial\DBAL\Types\Geometry\LineStringType
mapping_types:
_text: string
orm:
auto_generate_proxy_classes: "%kernel.debug%"
#naming_strategy: doctrine.orm.naming_strategy.underscore
entity_managers:
default:
dql:
numeric_functions:
ST_Contains: CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql\STContains
Contains: CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql\STContains
st_area: CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql\STArea
st_geomfromtext: CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql\GeomFromText
st_intersects: CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql\STIntersects
st_buffer: CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql\STBuffer
point: CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql\STPoint
auto_mapping: true
And my repository
public function findPointIn(){
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder = $queryBuilder->select('v')
->where(
$queryBuilder->expr()->eq(
sprintf("ST_Contains(v.geopoint , v.geopoint)"),
$queryBuilder->expr()->literal(true)
)
);
return $queryBuilder->getQuery()->getResult();
}
According to documentation, your numeric_functions names in config.yml must be lowercase. Change to:
numeric_functions:
st_contains: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STContains
contains: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Contains
st_area: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Area
st_geomfromtext: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\GeomFromText
st_intersects: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STIntersects
st_buffer: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STBuffer
point: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Point

Resources