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 / Example.fusion
Last active November 30, 2018 14:01
Ideas for status-rendering in the Neos-core as discussed by @grebaldi und @mficzel
#
# The rendering is implemented as special renderer for the error messages with a specific status code
#
# The fusion `error` path is rendered with only `site` and the `error` in the fusion context
#
error = Neos.Fusion:Case {
@context.notFoundNode = ${q(site).children('[uriPathSegment == 404]').get(0)}
404 {
condition = ${error.status == 404 && notFoundNode}
@mficzel
mficzel / Menu.fusion
Last active February 25, 2019 08:04
SKETCH :: Extract Neos.Neos:MenuData from Neos.Neos:Menu
//
// The prototype Menu is now based on template, like he already is
// the calulation of the menu items is passed over to MenuData
//
prototype (Neos.Neos:Menu) < prototype(Neos.Neos:Template) {
templatePath = 'resource://Neos.Neos/Private/Templates/FusionObjects/Menu.html'
node = ${node}
items = ${this.items}
entryLevel = ${this.startingPoint ? 0 : 1}
@mficzel
mficzel / Component.Organism.Head.fusion
Created March 18, 2019 17:02
Seperation of Presentation and Integration
#
# Presentational - prototype that encapsulates rendering of a page header
# without caring where title and description originate from
#
# Notice:
# - the base prototype is Neos.Fusion:Component
#
prototype(Vendor.Site:Component.Organism.Head) < prototype(Neos.Fusion:Component) {
title = ''
intro = ''
@mficzel
mficzel / ExampleController.php
Last active June 7, 2019 06:26
Backend Module with Fusion-AFX
<?php
namespace Test\BeModule\Controller;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\View\ViewInterface;
use Neos\Fusion\View\FusionView;
use Neos\Neos\Controller\Module\AbstractModuleController;
class ExampleController extends AbstractModuleController
{
prototype(Vendor.Site:Component.Organism.Header.Fixtures) < prototype(Neos.Fusion:DataStructure) {
mainMenuItems ...
languageMenuItems ...
}
@mficzel
mficzel / Form.fusion
Last active May 24, 2019 13:48
Idea: Neos.Fusion.Forms
//
// the form component creates a formDescription object and adds it to context `form`
//
prototype(Neos.Fusion.Form:Form) < prototype(Neos.Fusion.Forms:FormComponent) {
renderer = afx`
<form action={form.action}>
<div style="display: none">
<Neos.Fusion:Loop items={form.hiddenFields} itemName="hiddenField">
<input type="hidden" name={hiddenField.name} value={hiddenField.value} />
</Neos.Fusion:Loop>
@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
@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 / 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 / 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>