Details
-
Task
-
Resolution: Unresolved
-
High
-
None
-
None
-
None
Description
Generating URLs to the current location in templates is useful for creating social media data sharing links, metadata, parent location, etc.
When creating new content objects the use of {{ ez_url(location) }} the system crashes when previewing an unpublished draft. This is likely because there is no location as of yet. However I would expect the system not to crash, but just to create a placeholder URL.
Steps to reproduce:
- Install eZ Platform and run in dev mode
- Add a pagelayout template configuration in ezplatform.yaml
system default: pagelayout: "pagelayout.html.twig"
- Create template in templates/pagelayout.html.twig
{{ ez_url(location) }}
- Create new folder object
- Click preview
- Observe exception
An exception has been thrown during the rendering of a template ("When generating a UrlAlias route, either 'location', 'locationId', or 'contentId' must be provided.").
- After publishing and re-editing the template works ok (because the location exists)
Expectation:
- On eZ Platform 2.5 the system returned a URL (e.g. https://localhost:8000/site/view/content/123) for the content object when using url function instead of erroring out. I would hope for the same for 3.0 and higher that are using ez_url.