- Status changed to Closed: won't fix
12 months ago 7:24am 29 November 2023 - 🇫🇮Finland j-vee Turku, Finland
The issue with renderPlain ends up being is that it doesn't produce the same full HTML page as a HTTP request does and it therefore isn't the right tool here. What I did with the latest release though was that I changed file_get_contents function to use Drupal's HTTP Client service instead.
- 🇬🇧United Kingdom scott_euser
As in you want the actual html? Just ::render() instead of renderPlain() should do it maybe? Just needs to be on the right object for the level you want (eg, html, page, node, field level). Essentially if Drupal builds it for the end visitor it should also be able to build it for you without needing to make the http request
- 🇬🇧United Kingdom scott_euser
Here, "solution 2": https://www.hashbangcode.com/article/drupal-9-render-drupal-page-within-...
- Status changed to Active
12 months ago 6:43am 1 December 2023 - 🇫🇮Finland j-vee Turku, Finland
That solution 2 actually worked. Great suggestion, thanks!
It's a pretty convoluted way of putting the HTML render together. I'll probably make a separate service to handle this to keep things a bit cleaner.
Will include this in a future release so I'll re-open this for now.
- 🇫🇮Finland j-vee Turku, Finland
Latest update to dev-branch fixes this and there's now a new service that renders a given entity's view mode in HTML. Thanks!
I also generalised the service a bit so that it can now take:
- Entity type ID
- Entity ID
- Revision ID
- View mode
- Langcode
I think with those options this module could be extended to do a lot of things.
- Status changed to Fixed
12 months ago 7:08am 11 December 2023 Automatically closed - issue fixed for 2 weeks with no activity.