Download the PHP package flowpack/nodetemplates without Composer

On this page you can find all versions of the php package flowpack/nodetemplates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nodetemplates

Neos Node Templates

When using Neos CMS as an editor, you often work with nested node structures that have to be created manually. This packages aims at easing the editing workflow by automatically creating helpful child nodes and making useful modifications to node properties when creating new nodes in the Neos UI.

In contrast to child nodes that are defined in the regular node type definition (which cannot be removed by the editor), all modifications that are made when a template is applied can be changed or removed by the editor.

The desired node structure is defined in a declarative way in the NodeTypes.yaml under the path options.template.

TL;DR

  1. composer require flowpack/nodetemplates
  2. Add templates to your nodetypes configuration in NodeTypes.yaml, as described in the examples below
  3. Or use the command to dump the template based on your workspace

Hello world

The following example will add a text child node with the content "Hello World" to the main content collection of all pages that are created via the UI:

Using the node creation dialog

The Neos UI comes with a configurable node creation dialog. You can access the data entered in the node creation dialog in your node templates using EEL queries. You could let the editor choose between different dummy texts like this:

You can also access data from the node creation dialog if you use the showInCreationDialog feature:

Conditions and loops

Conditions

If you want to apply a template only under some conditions, you can use the when configuration key. It can be used in the main node template or in any child node template.

The following example only creates a text node if the option was selected in the creation dialog:

As a when condition that evaluates to false prevents the whole template (and all child templates) from being applied, its most common use case is conditional child node creation.

Loops

Loops can be used to create multiple child nodes. You can use withItems to define the items of the loop. When using EEL, be sure to return an array. The current item is available in EEL expressions as the item context variable.

The following example creates three different text child nodes in the main content collection:

We call conditions when and loops withItems (instead of if and forEach), because it inspires a more declarative mood. The naming is inspired by Ansible.

EEL context variables

There are several variables available in the EEL context for example.

Variable name Type Description Availability
data array<string, mixed> Data from the node creation dialog Global
site Node The site node in which the new node be created in Global
parentNode Node The node where the new utmost node will be created inside Global
~triggeringNode~ Node Deprecated: The new node itself which is triggering the template processing Global
item mixed The current item value inside a loop Inside withItems loop
key string The current item key inside a loop Inside withItems loop

Notice triggeringNode will be removed with version 3.0

Warning The behaviour of parentNode changed from version 1.x to version 2.2 Previously it referenced the parent node of the current template part and its nesting. With version 2.0 it was removed and 2.2 reintroduced the variable identifying the parent node of the first/utmost node that will be created.

Additional context

You can add more context variables to a template via the withContext setting. withContext takes an arbitrary array of items whose values might also contain EEL expressions:

Inside withContext the parent context may be accessed in EEL expressions, but sibling context values are not available. As withContext is evaluated before when and withItems, you can access context variables from withContext in withItems at the same level – but not the other way around.

If you want to use a custom EEL helper, make sure to register it in the package's Settings. EEL helpers configured for Neos.Fusion are not automatically available:

Fine-grained error handling, resuming with the next possible operation.

In the first step the configuration is processed, exceptions like those caused by an EEL Expression are caught, and any malformed parts of the template are ignored (with their errors being logged). This might lead to a partially processed template with some properties or childNodes missing.

You can decide via the error handling configuration Flowpack.NodeTemplates.errorHandling, if you want to start the node creation of this partially processed template (stopOnException: false) or abort the process (stopOnException: true), which will only lead to creating the root node, ignoring the whole template.

In case exceptions are thrown in the node creation of the template, because a node constraint was not met or the type field was not set, the creation of the childNode is aborted, but we continue with the node creation of the other left over parts of the template. It behaves similar with properties: In case a property value doesn't match its declared type the exception is logged, but we will try to continue with the next property.

Commands

Validate simple node templates

It might be tedious to validate that all your templates are working especially in a larger project. To validate the ones that are not dependent on data from the node creation dialog (less complex templates) you can utilize this command:

In case everything is okay it will succeed with X NodeType templates validated..

But in case you either have a syntax error in your template or the template does not match the node structure (illegal properties) you will be warned:

The standalone validation should detect errors and prevents editors having to deal with these errors at runtime.

For more complex templates, which are dependent on the node creation data, it is recommended to write separate tests. Currently, errors in templates depending on the data context will only be treated as warning, as they are probably not an issue at runtime.

Create template from node subtree

When creating a more complex node template (to create multiple pages and content elements) it can be helpful to take the current node subtree from your workspace as reference. For this case you can use the command:

options:

It will give you the output similar to the yaml example above. References to Nodes and non-primitive property values are commented out in the YAML.

More examples

For more examples have a look at the node templates demo package:

https://github.com/mindscreen/neos-nodetemplates-demo


All versions of nodetemplates with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
neos/neos Version ^7.3 || ^8.0
neos/neos-ui Version ~7.3.18 || ~8.0.13 || ~8.1.10 || ~8.2.10 || ~8.3.1 || ~8.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flowpack/nodetemplates contains the following files

Loading the files please wait ....