Rendering data from Entity model to the inspector using DataSource

Hey , I’m trying to render Data from Entity model to use them inside the inspector , I have made DataSource that gets all the objects properties like url and title , the problem is that the Value key in the output Json object is a string and I cannot store nseted array inside it to use it later in the typoscript file :

prototype(Mysite.Posts:Plugin) < prototype(TYPO3.Neos:Content) {
      templatePath = 'resource://Mysite.Posts/Private/Templates/NodeTypes/Post.html'
      element_title = ${q(node).property('etitle')}
} 

Inside the Nodetypes configuration file I hace this nodetype :

properties:
  etitle:
    type: string
    ui:
      reloadIfChanged: true
      label: 'List of Posts'
      inspector:
        group: image
        editor: TYPO3.Neos/Inspector/Editors/SelectBoxEditor
        editorOptions:
          dataSourceIdentifier: mysite-posts-test

My question is how to get more than the Post title ? the nodetype return only the title of the post using the DataSource Value key inside the returned array, how can I get the title and the other properties inside that Entity ? can I do that for example inside the typoscript ? :

prototype(Mysite.Posts:Plugin) < prototype(TYPO3.Neos:Content) {
          templatePath = 'resource://Mysite.Posts/Private/Templates/NodeTypes/Post.html'
          element = ${q(node).property('etitle')}
          element_title = ${q(node).property('etitle')['getTitle']}
          element_url = ${q(node).property('etitle')['getUrl']}
    } 

this is the getData method inside the DataSource :

/**
 * Get data
 *
 * @param NodeInterface $node The node that is currently edited (optional)
 * @param array $arguments Additional arguments (key / value)
 * @return array JSON serializable data
 */
public function getData(NodeInterface $node = NULL, array $arguments)
{
   $postsArr = array();

   foreach ($this->postRepository->findAll() as $post) {
      $postsArr[] = array(
         'value' =>  $teaser->getPostTitle(),
         'label' => $teaser->getPostTitle(),
         'group' => '',
         'icon' => '',
      );
   }

   return $postsArr;
}

I hope you understood my question :slight_smile:

Thank you

Hey Asem

It’s not really supported in an easy way in the core at the moment, so you have to do a bit of workaround.

I recently did it for the neos.io blog posts

See the EditorsDataSource and DataHelper https://github.com/neos/Neos.NeosIo/commit/9c2def8944d81df15cdf237f4b2954deb80e2f00

Thank you @aertmann , I made it already using Custom TypoScript Object and link it with php class that fetch all the objects data from the persistence and then return all the data to the TypoScript object.

Can you please send me a link for this service : TYPO3\Neos\Domain\Service\UserService;

Thanks again.

Hi @khatib_a,
I’m not sure, but maybe you are looking for the Class-File?
So, this would help:

local: /Packages/Application/TYPO3.Neos/Classes/TYPO3/Neos/Domain/Service/UserService.php
github: https://github.com/neos/neos/blob/master/Classes/TYPO3/Neos/Domain/Service/UserService.php

Thanks @mad that’s what I wanted to see :slight_smile:

I wrote a guide for Neos 2.3 LTS that explains on how to do this without a custom Fusion object / Eel helper: Guide: How to select entities in the inspector (Neos 2.3 LTS)