Typoscript2-Prototype with more then one ancestor?

Hi together,
is it possible to use more than one ancestor in Prototyping with typoscript2?
In yaml-files, there is the supertype-possibilities. So I can combine the fields of different nodeTypes.

In ts2, I can’t find something similar.
I would like to use all properties of two Ancestors. Normally I can do it with good inheritance-logic.
But in the current situation, each Ancestor-prototype-properties has no dependency directly on each other in most of the child-prototypes, there are inherit from one of them. So flowQueries would have problems in other prototypes, if I would write all of them in one Big-Ancestor.

prototype(VendorName.SiteName:NewTypeWithOwnProps) < prototype(VendorName.SiteName:AncestorA) < prototype(TYPO3.Neos.NodeTypes:AncestorB) {

doesn’t work :thumbsdown:.
I could write an more detailed child-prototype with less abstraction an break apart in ancestors, but so I have to rewrite properties in different prototypes a few times.

Maybe there is a really pretty solution, but I stumble always blindly without finding it. So I have to ask once more:
####Did someone knows a working Neos-solution or a good work-around?

I would consider this not good practice. NodeTypes and TS should be assembled instead of inherited if possible.

'Vendor.Site:CompoundNodeType':
  superTypes:
    'Vendor.Site:HeadlineMixin': TRUE
    'Vendor.Site:ImageMixin': TRUE

In TS2 this can be used like this:

prototype(Vendor.Site:CompoundNodeType) < prototype(TYPO3.TypoScript:Array) {
  headline = Vendor.Site:Headline
  image = Vendor.Site:Image
}

Regards Martin

Hi @mficzel,
you are right. There is a huge field to lern better practice for me :rolling_eyes:.

I thought, it would be nice to combine the flowQuery definitions and other logic stuff of both of the protoypes there was written allready. So I do not have to rewrite double property-definition with the same final result only in an other context.
But if there is not such a key/term in Neos, I will write it twice.

Sometimes I did a workaround and later I found an other term. With this and friend google there was suddenly a much simpler solution.
Thanks!

To reuse FlowQueryDefinitions you can do the following:

# define
prototype(Vendor.Site:CustomFlowQueryPrototype) < prototype(TYPO3.TypoScript:Value) {
  value = ${q(node).children().get()}
}

# use
prototype(Vendor.Site:CustomNodePrototype) < prototype(TYPO3.TypoScript:Template) {
  items = Vendor.Site:CustomFlowQueryPrototype
}

Warning: Untestet code!

Hey martoro,
once more: Neither I knew this shorthand solution, nor I know the right term/principle to ask for. Thank you!
It works. I get the properties wrapped in a [div]-tag as a string and can use them in the Fluid-Template. Would be great to get the properties one by one.

So, did someone know: is it possible to get the «items» split as properties, like created in the ancestor?
If I try to use a particular property in template like «{items.properyXY}», an error is throwing: $subject must be an object or array, string given.
Could I call the «items = Vendor.Site:CustomFlowQueryPrototype»-part something different, to get the properties from the inherited Prototype as array or object, to use those directly in the Fluid-Tempalte?

# define
prototype(Vendor.Site:CustomFlowQueryPrototype) < prototype(TYPO3.TypoScript:Value) {
    value.child = ${q(node).children().get()}
    value.id = ${q(node).property('id')}
    value.class = ${q(node).property('class')}
    value.propertyXY = "blabla"
}

The Value the Object TYPO3.TypoScript:Array returns is the concatenated results of all subkeys as a string. That is good for outputting stuff but you cannot access subProperties. If you want do do that TYPO3.TypoScript:RawArray is your friend.

# define array prototype
prototype(Vendor.Site:CustomRawArrayPrototype) < prototype(TYPO3.TypoScript:RawArray) {
  children = ${q(node).children().get()}
  parents = ${q(node).parents().get()}
}

# use 
prototype(Vendor.Site:CustomNodePrototype) < prototype(TYPO3.TypoScript:Template) {
  @context { 
     customRawArrayPrototypeResult = Vendor.Site:CustomRawArrayPrototype
  }
  children = ${customRawArrayPrototypeResult.children}
  parents = ${customRawArrayPrototypeResult.parents}
}

Warning: Untestet code!

Even though that should work please never do it. That puts a huge amount of data into the context.
Rather than using @context make it a simple property of the CustomNodePrototype and use this to access it.

@mficzel and @christianm: Thank’s for your helping infos.
Both let me consider Prototype-creation and the possibilities from new perspectives.

@christianm do you mean something like this?

# define array prototype
prototype(Vendor.Site:CustomRawArrayPrototype) &lt; prototype(TYPO3.TypoScript:RawArray) {
  children = ${q(node).children().get()}
  parents = ${q(node).parents().get()}
}

# use 
prototype(Vendor.Site:CustomNodePrototype) &lt; prototype(TYPO3.TypoScript:Template) {
  customRawArrayPrototypeResult = Vendor.Site:CustomRawArrayPrototype
  children = ${this.customRawArrayPrototypeResult.children}
  parents = ${this.customRawArrayPrototypeResult.parents}
}

I was not shure wether that would work but you are right that would be a way better solution.

1 Like

@mad We had some insightful conversations in Slack, and I even promised to try to document it, but still haven’t found the time so far. Maybe this discussion would help you understand @context a bit better: http://tinyurl.com/typoscript-context

Ok, I think I was a bit harsh in here with my “never do it”. Correct is: Be careful when doing is and keep in mind that…

Harshness or shock: best for memorizing :laughing: :thumbsup:.
I’m glad you help me.
All the best

@dimaip: Thanks for the link. Will have a look at, with pleasure.