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

Hot to get the transformed content area only? #375

Closed
jensens opened this issue Aug 15, 2017 · 1 comment
Closed

Hot to get the transformed content area only? #375

jensens opened this issue Aug 15, 2017 · 1 comment

Comments

@jensens
Copy link
Sponsor Member

jensens commented Aug 15, 2017

Problem: We need to deliver the rendered Mosaic based content core area over a rest-api together with other information as JSON. (i.e. {'title': 'sometitle', 'content': 'somecontent', 'other': 123}

What we tried: Calling getMultiAdapter with name layout_view does not transform the output. So we need to transform this programmatically. Calling the transformchain (plone.transformchain.zpublisher.applyTransforms) seems not the right way - also we would need some fake request. Calling the transforms of plone.app.blocks.transforms.* one after each other does not feel right either.

Question: Whats the recommended way to render the tiles programmatically?

cc @datakurre

@datakurre
Copy link
Member

datakurre commented Aug 15, 2017

@jensens See existing content tile for an example:

https://github.com/plone/plone.app.standardtiles/blob/master/plone/app/standardtiles/existingcontent.py#L179

  1. parse lxml tree with the contents of your content area wrapped into <html><body></body></html>.
  2. pass the current request with tree to plone.app.blocks.tiles.renderTiles.

That will mutate the given lxml tree by expanding tiles in it. Tiles are expanded with the context of the request (by passing request to plone.subrequest).

This should work for all the use cases I can think of. The other transforms are to support panels and ESI. Mosaic also includes some extra transforms to support site layouts. In addition, I'm adding a one new transform into standardtiles to optimize rendering of default HTML tile (long story: originally there were not HTML tiles but HTML was baked into content layout, HTML tile was refactored into normal tile for Castle, the new transform would cook all HTML tiles in optimized fashion to only leave "real tiles" for rendedTiles transform).

@jensens jensens closed this as completed Aug 25, 2022
krissik pushed a commit that referenced this issue Mar 11, 2024
Disable CSRF protection during the setting of TG attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants