Slide 1

Slide 1 text

Importing & Exporting Nodes with Neos

Slide 2

Slide 2 text

Karsten Dambekalns Neos and Flow developer 37 years old lives in Lübeck is a Flownative 1 wife, 3 sons 1 manual espresso maker likes canoeing & climbing

Slide 3

Slide 3 text

Where is my data?

Slide 4

Slide 4 text

A node is the smallest unit in which Neos stores content. A node can represent a document or pieces of content on a document, so nodes can be nested. Node

Slide 5

Slide 5 text

The content repository is the storage for all nodes. Content Repository

Slide 6

Slide 6 text

Database The content repository uses a regular relational database to store nodes and their properties. Actively dealing with that should be the exception to the rule.

Slide 7

Slide 7 text

Site package In Neos the site package acts as a container for all assets a site needs and can also contain the site content.

Slide 8

Slide 8 text

Sites.xml Site content can be exported to an XML file in the site package or elsewhere. That file contains the structure, content. Used assets of a site can be contained there or be exported alongside.

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Common Tasks

Slide 11

Slide 11 text

Import freshly kickstarted site

Slide 12

Slide 12 text

$  flow  kickstart:site  -­‐-­‐package-­‐key  Neos.Sprint   -­‐-­‐site-­‐name  'Neos  Sprint  Nuremberg'   Created  .../Sites.xml   Created  .../Root.ts2   Created  .../Default.html   Created  .../NodeTypes.yaml   $  flow  site:import  -­‐-­‐package-­‐key  Neos.Sprint   Import  of  site  "Neos  Sprint  Nuremberg"  finished.

Slide 13

Slide 13 text

Export to the site package

Slide 14

Slide 14 text

$  flow  site:export  -­‐-­‐package-­‐key  Neos.Sprint   All  sites  have  been  exported  to  package   "Neos.Sprint".

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

$  flow  site:export  -­‐-­‐tidy  -­‐-­‐package-­‐key  Neos.Sprint   All  sites  have  been  exported  to  package   "Neos.Sprint".

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Use the tidy option if you want to be able to read diffs between states.

Slide 19

Slide 19 text

Export to standard output

Slide 20

Slide 20 text

$  flow  site:export  -­‐-­‐tidy  >  site-­‐export.xml   $  flow  site:export  -­‐-­‐tidy                                

Slide 21

Slide 21 text

Export to a file

Slide 22

Slide 22 text

$  flow  site:export  -­‐-­‐filename  site-­‐export.xml   All  sites  have  been  exported  to  "site-­‐ export.xml".

Slide 23

Slide 23 text

Export to a package or file to have resources exported to individual files.

Slide 24

Slide 24 text

Multiple site exports

Slide 25

Slide 25 text

Why would you need more than one site export in a project?

Slide 26

Slide 26 text

Showcase available node types.

Slide 27

Slide 27 text

Provide a fixture for automated testing.

Slide 28

Slide 28 text

Have a “demo site” giving an impression of how the final site could look like.

Slide 29

Slide 29 text

Deliver base structure for a site to the client. Removal of nodes is not supported, import only adds/updates currently.

Slide 30

Slide 30 text

$  flow  site:export  -­‐-­‐filename  site-­‐base.xml   All  sites  have  been  exported  to  “site-­‐base.xml".   $flow  site:prune   All  sites  and  content  have  been  removed.   $flow  site:import  -­‐-­‐package-­‐key  Neos.Sprint   Import  of  site  "Neos  Sprint  Nuremberg"  finished.   $flow  site:import  -­‐-­‐filename  base-­‐structure.xml   Import  of  site  "Neos  Sprint  Nuremberg"  finished.

Slide 31

Slide 31 text

Creating content through code

Slide 32

Slide 32 text

Warning: Only some user serviceable parts inside

Slide 33

Slide 33 text

Option I Generate XML

Slide 34

Slide 34 text

Option II Create nodes in PHP

Slide 35

Slide 35 text

Generating valid node names use  \TYPO3\TYPO3CR\Utility;   Utility::renderValidNodeName($name);

Slide 36

Slide 36 text

Use NodeTemplate $tpl  =  new  NodeTemplate();   …   $node  =  $parent   -­‐>createNodeFromTemplate($tpl);

Slide 37

Slide 37 text

Handle node variants in all workspaces in case an editor has modified it and not published it yet. Otherwise the data gets overwritten again when the editor publishes.

Slide 38

Slide 38 text

When importing, re-use existing tooling.

Slide 39

Slide 39 text

This will avoid memory and performance issues by batch processing.

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Generate a lot of nodes for up-front testing, to see how the system will perform when you imported in the end.

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Import performance

Slide 44

Slide 44 text

When using the Node API performance issues will come up eventually.

Slide 45

Slide 45 text

You may need to use NodeData directly.

Slide 46

Slide 46 text

Do not get used to working with NodeData. While needed for fast and memory-conserving imports, it is not public API and should be used with great care.

Slide 47

Slide 47 text

Be prepared to handle things like updating the node index, flushing the content cache and setting uriPathSegment manually.

Slide 48

Slide 48 text

Option III Do not import

Slide 49

Slide 49 text

Fetch content on-the-fly If you can fetch (some) of the content from an external source, like Redis or Elasticsearch, you could just use an Eel helper in TypoScript to pass it to the rendering. No “real” nodes, but still cached in the content cache, hence fast.

Slide 50

Slide 50 text

Option IV Content Object Proxy

Slide 51

Slide 51 text

Use content objects If you have your data in some Flow application anyway, or it makes sense to have it as entities, you can add a content object to a node. The node acts as a proxy to the entity, exposing its properties.

Slide 52

Slide 52 text

Questions? Ideas?

Slide 53

Slide 53 text

karsten@flownative.com www.flownative.com @kdambekalns share your thoughts

Slide 54

Slide 54 text

www.flownative.com