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

Custom variables are not correctly exposed in legacy templates when doing a sub-request

    XMLWordPrintable

Details

    Description

      When doing a ez_content:viewLocation sub-request, it is possible to pass extra parameters to the sub-ViewController. These extra parameters will then be passed to the underlying ViewProvider.

      This is basically what was possible in legacy when doing node_view_gui. See legacy documentation on this.

      This works perfectly when using Twig templates as variables are correctly passed, but when you fallback to legacy rendering, those parameters are passed as user parameters which then are merged into $view_parameters template variable.
      Direct consequence is that needed variables cannot be accessed directly, but only through $view_parameters.my_var (instead of just $my_var.

      Example

      From a Twig template, we do a sub-request to display a location and we don't have a Twig template yet for it (so fallback to legacy ViewProvider\Location).

      {{ render(
          controller(
              "ez_content:viewLocation",
              {
                  "locationId": someLocationId,
                  "viewType": "block_item",
                  "params": {"image_class": "contentgrid"}
              }
          )
      ) }}
      

      Legacy template:

      {* We expect $image_class to be available *}
      Expected image class: {$image_class} (will be null)
      What we have: {$view_parameters.image_class} (will be "contentgrid")
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jerome.vieilledent-obsolete@ez.no Jérôme Vieilledent (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: