Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to ditch fluid? #184

Closed
bernhardberger opened this issue Aug 15, 2020 · 8 comments · Fixed by #552
Closed

Any way to ditch fluid? #184

bernhardberger opened this issue Aug 15, 2020 · 8 comments · Fixed by #552
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@bernhardberger
Copy link

bernhardberger commented Aug 15, 2020

Looking at the templates and actually currently working on something (very) similar to EXT:headless regarding content json rendering..

Any ideas on how to get rid of fluid? It's a massive pain in the butt and so extremely error prone when needing to write nested JSON structure..

Extbase actually would offer the possibility to use a php based view, but it's impossible to XCLASS the ActionController and the resolveViewObject() method doesn't provide a hook/event to extend/alter the algorithm. All it would need would be a way to inject another php namespace for path resolving..

Could be: @overrideVendorName/@overrideExtensionName/View/@originalVendorName/@originalExtensionName/@controller/@action.

This would actually be useful in TYPO3 in general, not just in context of EXT:headless

@tmotyl
Copy link
Collaborator

tmotyl commented Aug 17, 2020

Hi
Indeed, being able to skip fluid for integrating external extensions headless ready would be a great improvement.
It would be great to investigate and duscuss it further. Some changes might be also good to include in the core.
Do you have some ideas how to implement it in practice?

@bernhardberger
Copy link
Author

bernhardberger commented Aug 17, 2020

As I said above I think all it would take would be an event/hook in the resolveView() and/or resolveViewObject() method of the `ActionController' and you'd have endless possibilities.

The best approach I think would be a PHP based view. Especially if you have access to controllerContext when deriving from AbstractViewnothing stops you from calling ViewHelpers or using DataProcessors (maybe have a look at cvc_twig, they actually have a nice and really clean implementation of integrating twig).

//Edit: removed an unfinished sentence at the end.

@tmotyl
Copy link
Collaborator

tmotyl commented Aug 20, 2020

@bernhardberger your comment sounds unfinished?
Can you prepare a POC patch to the core which would solve the issue? do they in cvc_twig solve the issue already?

@theLine
Copy link
Contributor

theLine commented Aug 21, 2020

I'm also interested in removing Fluid from JSON rendering process.
@bernhardberger I'd be nice if you could provide an example from your extension or an PoC like tmotyl said.

If you need any help, please hit me up.

@tmotyl
Copy link
Collaborator

tmotyl commented Aug 21, 2020

Wouldnt the way to go be introducing custom ViewResolverInterface implementation?

@bernhardberger
Copy link
Author

bernhardberger commented Aug 21, 2020

Wouldnt the way to go be introducing custom ViewResolverInterface implementation?

Most likely - yes. I'm hesitating to post anything because I'm
a) trying to figure out what's changed between 9.5 and 10 regarding this.
b) check if it could be done via DI in 10
c) what the best way would be to provide a PHPTEMPLATE cObject

I've linked the cvc_twig extension as they actually provide a very clean implementation of a custom templating engine. They however also don't have a way around existing Extbase extension ActionControllers and you'd still need to overwrite $defaultTemplateViewObject on existing controllers.

And whilst I absolutely love Fluid (Imho it's one of the best and cleanest templating engines out there and I can't wait for fluid v3) - I think it's overkill and a massive pain when dealing with plain JSON output, and way too error prone, especially when you need to do loops.

That all being said: I'm looking for a clean, core near implementation possibility, I don't want to hack something together that's half-assed and potentially breaks in every new core version.. Seeing that the internal structure of resolving the view in extbase changed quite a bit from 9.5 to 10 I'm hesitant to submit a PR/post a PoC without checking why it has changed and where to road leads to beforehand..

PPS: I also don't want to sacrifice on rendering FLUIDTEMPLATE partials from the PHP based view as there certainly ARE usecases where fluid comes in handy..

@tmotyl
Copy link
Collaborator

tmotyl commented Sep 9, 2020

@bernhardberger did you have time to play with the ViewResolverInterface approach?

@lukaszuznanski lukaszuznanski added enhancement New feature or request help wanted Extra attention is needed labels Nov 6, 2020
@lukaszuznanski
Copy link
Collaborator

I think we can come back to this issue and check if it's possible in v11 via DI, as we are close to release of version v3.0.0 for TYPO3 v11, so maybe we can ditch fluid anyway, as we don't have to keep compatibility with v9 and v10.

twoldanski added a commit that referenced this issue Feb 16, 2023
resolves: #184

Feature if enabled replaces rendering templates in fluid in frontend context with php templates in order to simplify output json.

 Templates paths resolving is the same as in fluid, feature seeks just files with php extension,

 In php template you should just echo json_encode([...]);

How to enable:

- add new `headless.overrideFluidTemplates` flag to LocalConfiguration
- add to typoscript settings for desired plugin, flag `phpTemplate`=1 in order to override fluid templates
twoldanski added a commit that referenced this issue Feb 20, 2023
resolves: #184

Feature if enabled replaces rendering templates in fluid in frontend context with php templates in order to simplify output json.

 Templates paths resolving is the same as in fluid, feature seeks just files with php extension,

 In php template you should just echo json_encode([...]);

How to enable:

- add new `headless.overrideFluidTemplates` flag to LocalConfiguration
- add to typoscript settings for desired plugin, flag `phpTemplate`=1 in order to override fluid templates
lukaszuznanski pushed a commit that referenced this issue Mar 1, 2023
resolves: #184

Feature if enabled replaces rendering templates in fluid in frontend context with php templates in order to simplify output json.

 Templates paths resolving is the same as in fluid, feature seeks just files with php extension,

 In php template you should just echo json_encode([...]);

How to enable:

- add new `headless.overrideFluidTemplates` flag to LocalConfiguration
- add to typoscript settings for desired plugin, flag `phpTemplate`=1 in order to override fluid templates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants