neos-development-collection icon indicating copy to clipboard operation
neos-development-collection copied to clipboard

FEATURE: Add helpers to fetch nodes in ways similar to `context()` operation

Open kdambekalns opened this issue 1 year ago • 7 comments

Description

Prior to Neos 9 it was possible to use the context() operation to fetch nodes, e.g. from a different workspace or in different dimension values. This was useful e.g. if you need to create a link to such a node.

With Neos 9 the context() operation no longer exists, a new, possibly improved way should be made available.

Ideally the new way could be added to a potential Neos 8.4 to make it forward-compatible.

Current state

In Neos9-beta10 and before a hard to decipher error is shown, indicating that context does not exist.

Method "context" is not callable in untrusted context

Possible Solution

  • q(node).inWorkspace('live') to fetch a node in a certain workspace
  • to fetch a node with a certain set of dimension values
  • to include invisible nodes in the results
  • …?

kdambekalns avatar May 27 '24 11:05 kdambekalns

I'm willing to coordinate and hopefully implement this. I need your help, though, to come up with a nice API. So let's hear your suggestions for the operations we need…

kdambekalns avatar May 27 '24 11:05 kdambekalns

I use the same three as in your list. So here my first quick suggestions:

How about withDimensionsCombination(<dimensions>[, <targetDimensions>]) for something like this:

q(site).context({'dimensions': this.dimensions.dimensions, 'targetDimensions': this.dimensions.targetDimensions})

And includeInvisible([<bool>]) to replace q(node).context({'invisibleContentShown': true})

Sebobo avatar May 27 '24 11:05 Sebobo

regarding legacy invisibleContentShown:

Regarding includeInvisible([<bool>]) we should definitely use the disabled naming here (https://github.com/neos/neos-development-collection/issues/4312) and we actually prepared with the introduction of subtree tags new possibilities than just disabled and not disabled but also custom subtree tags. That should ideally be also reflected via the api but there might be an abstraction to simplify the disabled case:

q(node).withoutDisabled()
q(node).withDisabled()

and generic tags:

q(node).withRestrictedVisibility([])
q(node).withRestrictedVisibility(['disabled'])

i found it actually super hard to think of the namings here and until bastians cr privileges are done it might be to soon to advance here ... unless of course well coordinated.

regarding targetDimensions

i have to ask bernhard but one just uses a full dimension space point here ... so the api would be

withDimension(['language' => 'en'])

Fyi regarding dimension we already also have this eel helper in place which can do a lot of crazy stuff (for neos seo)

Neos.Dimension.findVariantInDimension(node, 'language', 'en_UK')

mhsdesign avatar May 27 '24 12:05 mhsdesign

TIL: Node.Dimension.…, see e.g. https://github.com/neos/neos-seo/blob/4.x/Resources/Private/Fusion/Metadata/AlternateLanguageLinks.fusion

kdambekalns avatar May 29 '24 19:05 kdambekalns

https://github.com/neos/neos-development-collection/pull/5130 would reintroduce the 8.3 syntax for workspaceName, dimensions, invisibleContentShown (untested yet)

mhsdesign avatar Jun 05 '24 13:06 mhsdesign

As #5130 is merged, can we close this?

dlubitz avatar Jan 29 '25 08:01 dlubitz

As i wrote

The context operation should thus not be seen as forever-staying feature and will likely be deprecated and replaced with more explicit ways which fit better the current naming scheme and API.

I though well keep discussing ideas here for a new API - as the title suggests "similar to context()". I just implemented the old thing no one actually really wanted lol :'D

mhsdesign avatar Jan 29 '25 10:01 mhsdesign