Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Importing & Exporting Nodes with Neos

Importing & Exporting Nodes with Neos

Wondering how to use the site import / export features during development and while delivering / maintaining a project? Do you have the need to import content from various sources into your brand new Neos project?
These slides give you an overview of how to get the most out of the import / export commands and will show you how an import of content can be done through code in various ways.

Karsten Dambekalns

July 18, 2015
Tweet

More Decks by Karsten Dambekalns

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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.
  4. Site package In Neos the site package acts as a

    container for all assets a site needs and can also contain the site content.
  5. 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.
  6. $  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.
  7. Use the tidy option if you want to be able

    to read diffs between states.
  8. $  flow  site:export  -­‐-­‐tidy  >  site-­‐export.xml   $  flow  site:export

     -­‐-­‐tidy   <?xml  version="1.0"  encoding="UTF-­‐8"?>   <root>    <site  name="Neos  Sprint  Nuremberg"  state="1"   siteResourcesPackageKey="Neos.Sprint"   siteNodeName="sprint">      <nodes  formatVersion="2.0">        <node  identifier="d8d4ae92-­‐53e0-­‐ ef20-­‐9d5e-­‐6fd5578c9713"  nodeName="sprint">          <variant  sortingIndex="100"  workspace="live"   nodeType="TYPO3.Neos.NodeTypes:Page"  version="1"  
  9. Deliver base structure for a site to the client. Removal

    of nodes is not supported, import only adds/updates currently.
  10. $  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.
  11. Use NodeTemplate $tpl  =  new  NodeTemplate();   …   $node

     =  $parent   -­‐>createNodeFromTemplate($tpl);
  12. 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.
  13. Generate a lot of nodes for up-front testing, to see

    how the system will perform when you imported in the end.
  14. 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.
  15. Be prepared to handle things like updating the node index,

    flushing the content cache and setting uriPathSegment manually.
  16. 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.
  17. 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.