Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-31716

ez_url Twig function crashes on location linking with unpublished draft

    XMLWordPrintable

Details

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: High 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jani.tarvainen@ibexa.co Jani Tarvainen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: