Skip to content

Instantly share code, notes, and snippets.

View mficzel's full-sized avatar

Martin Ficzel mficzel

  • sitegeist neos solutions GmbH
  • Germany, Hamburg
View GitHub Profile
@mficzel
mficzel / ContactController.php
Last active July 3, 2020 08:17
Contact-form example with Neos.Fusion.Form and a custom controller
<?php
namespace Vendor\Site\Controller;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\SwiftMailer\Message as SwiftMailerMessage;
class ContactController extends ActionController
{
/**
@mficzel
mficzel / 1_Usage.fusion
Last active April 10, 2020 09:31
Filter list by reference intersection
videos = Neos.Fusion:Loop {
items = Vendor.Site:VideoNodesByTag {
tags =
}
renderer = afx`<div>{item.title}</div>`
}
@mficzel
mficzel / Query.sql
Created January 28, 2020 14:39
Neos - Find out which nodes were added below a specific type
SELECT node.nodetype, parent.nodetype, count(*) FROM `neos_contentrepository_domain_model_nodedata` AS node
JOIN `neos_contentrepository_domain_model_nodedata`
AS parent
ON node.parentpath = parent.path
WHERE parent.nodetype='Vendor.Site:NodeType'
GROUP by node.nodetype
@mficzel
mficzel / FusionController.php
Created November 21, 2019 12:07
Using the Fusion View in a Backend Module
<?php´
namespace Vendor\Site\Controller;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Controller\Module\AbstractModuleController;
use Neos\Fusion\View\FusionView;
class FusionController extends AbstractModuleController
{
/**
@mficzel
mficzel / WrapperComponent.fusion
Last active May 28, 2021 06:22
Wrapper components
prototype(Vendor.Site:Example) < prototype(Neos.Fusion:Component) {
foo = null
bar = null
renderer = Neos.Fusion:Component {
# pass all outer props to the renderer
@apply.props = ${props}
# alternatively pass explicit props to the renderer
foo = ${props.foo}
@mficzel
mficzel / source.fusion
Created October 17, 2019 10:58
Fusion DSL json`...`
jsonLd = json`{
"@context": "http://schema.org",
"@type": "Organization",
"name": "Neos",
"url": "${__someExpression__}",
"contactPoint:$<Neos.Fusion:Map>": {
"items": "${__someExpression__}",
"itemRenderer": {
"@type": "ContactPoint"
"contactType": "${__someExpression__}",
@mficzel
mficzel / Example.fusion
Last active August 27, 2019 12:58
Create custom validation-errors in Neos.Flow
// render all validation errors of current request
renderer = afx`
<div @if.hasErrors={request.internalArguments.__submittedArgumentValidationResults.flattenedErrors}>
ERORR
<ul>
<Neos.Fusion:Loop items={request.internalArguments.__submittedArgumentValidationResults.flattenedErrors} itemKey="path" itemName="errors">
<Neos.Fusion:Loop items={errors} itemName="error">
<li>{path} - {error}</li>
</Neos.Fusion:Loop>
</Neos.Fusion:Loop>
@mficzel
mficzel / example.fusion
Created July 5, 2019 09:54
Translations with arguments and quantity
hotelCount = ${Translation.id('foundHotelsLabel').source('HotelList').package('Vendor.Site').arguments({count:12, location:'timbuktu'}).quantity(12).translate()}
@mficzel
mficzel / error.fusion
Last active June 11, 2019 15:09
Translated 404 Document with Neos 4.3
error {
// find the 404 document
@context.notfoundDocument = ${q(site).children('notfound').get(0)}
// use german not found page if the request uri starts with /de
@context.notfoundDocument.@process.inGerman = ${q(value).context({'dimensions': {'language': ['de']}, 'targetDimensions': {'language': 'de'}}).get(0)}
@context.notfoundDocument.@process.inGerman.@if.requestStartsWithDe = ${String.startsWith(request.httpRequest.serverParams.REQUEST_URI, '/de')}
// render the 404 document via /root path
@mficzel
mficzel / Settings.yaml
Created May 28, 2019 07:54
Image Variants Configuration for Neos 4.3
Neos:
Media:
# show Variants tab in the inspector
Browser:
features:
variantsTab:
enable: true
# define Variant presets