[Neos] Computed properties & JSON

Dmitri Pisarev dimaip at gmail.com
Fri Apr 3 09:02:46 CEST 2015


Hey Tristan! I'm not an expert at this stuff, but I would try to do the
following:
1. Create TS object and have all of the properties processed the way you
like: with standard eel helpers, with custom eel helpers or with custom
processors.
2. Have a separate Fluid template for it and render JSON with custom Fluid
ViewHelper (or is there one already?). Or maybe even fix JSON.stringify if
it really doesn't work the way it should?

This way your model is defined in TS, and you just switch different views
for getting HTML and JSON output.

On Thu, 2 Apr 2015 at 20:00 Tristan Koch <typo3.org at tknetwork.de> wrote:

> Hi,
>
> I need to model categories (with title, image, ...) that have products
> (with article number, ...). For that I defined custom document nodes (in
> NodeTypes.yaml) for category and product that appear like normal pages and
> can be edited in the Neos backend. Now, one requirement is to render
> products of a given category in both HTML and JSON (in case you wonder, the
> purpose of the JSON is to configure a JavaScript based product filter).
>
> 1) Computed node properties
>
> The product page has a user editable property article. This property
> should be normalized (all lowercase, white spaces removed). I could use a
> processor for that, but then I would need to duplicate code when later
> generating the same attribute for the JSON representation. The workaround I
> came up with involves a custom TypoScript class that extends from
> TemplateImplementation. It works and properties set here can be read
> elsewhere. Anyway, I would much prefer to add properties to the node model
> itself but I don't see how.
>
> gist.github.com/trkoch/6b432c224f785ecfd6da
> (sorry, I'm not yet allowed to post links)
>
> 2) JSON from nodes
>
> Eel has a JSON.stringify helper but it is very limited. The solution I
> came up with uses another TypoScript class and assigns a variable to the
> template that includes the JSON. Here I would rather like to extend the
> category node with a property I can call from Eel/FlowQuery that returns
> the JSON.
>
> gist.github.com/trkoch/ff7b2d7a347563297d16
> (sorry, I'm not yet allowed to post links)
>
> I've already read most of the online documentation and some of the Neos
> code but I really don't see how this can be done in a cleaner way. Any
> hints would be greatly appreciated.
>
> Regards
> Tristan
>
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
>


More information about the Neos mailing list