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

Make existing templates part of the standard design

    Details

    • Sprint:
      [2.2] Sprint 1
    • Story Points:
      3

      Description

      The ezplatform-standard-design package must ensure that the kernel's templates can be overridden using the design engine. The outcome should be that any template from our packages can be customized by an integrator by redefining them in their own, enabled design.

      Expectations

      As an eZ Platform integrator, I can replace templates used by eZ Platform

      Given any template from the following packages:
        "ezsystems/ezpublish-kernel"
        "ezsystems/repository-forms"
        And an URI that uses a given template from those packages
       When I copy that template to the same path inside "app/Resources/views/themes/standard"
        And I render that URI
       Then my copy is used instead of the original template
      

      Possible approach

      Make existing templates part of the standard design.

      First, we must add the existing templates directories (such as kernel's) to the standard design. ezplatform-design-engine has support for that:

      ezdesign:
        templates_theme_paths:
            standard:
              - "%kernel.root_dir/../vendor/ezsystems/ezpublish-kernel/eZ/Bundle/EzPublishCoreBundle/Resources/views"
              - "%kernel.root_dir/.../vendor/ezsystems/ezpublish-kernel/eZ/Bundle/EzPublishDebugBundle/Resources/views"
      

      We may want to add those templates directories from the package they are defined in, since ezplatform-design-engine will error out if a path that doesn't exist is added to this list.

        Issue Links

          Activity

          Hide
          Bertrand Dunogier added a comment -

          I have quickly tested what is described above:
          1. add path of existing templates to templates_theme_paths for the standard design
          2. decorated ezdesign.twig_theme_loader with a custom twig loader, and replaced path to known templates path (ex: EzPublishCoreBundle:: with the @ezdesign version.

          As far as I can tell, the templates from the replaced path are correctly changed to use the design engine. In my decorated class, I did a simple str_replace of known paths in the following methods: getSourceContext(), getCacheKey(), isFresh(), exists(), getSource(), findTemplate().

          I could then test that by dropping a template at app/Resources/views/themes/standard/pagelayout.html.twig, after clearing cache, my custom template was used instead of the one from EzPublishCoreBundle.

          Show
          Bertrand Dunogier added a comment - I have quickly tested what is described above: 1. add path of existing templates to templates_theme_paths  for the standard  design 2. decorated ezdesign.twig_theme_loader  with a custom twig loader, and replaced path to known templates path (ex: EzPublishCoreBundle:: with the @ezdesign  version. As far as I can tell, the templates from the replaced path are correctly changed to use the design engine. In my decorated class, I did a simple str_replace  of known paths in the following methods: getSourceContext() , getCacheKey() , isFresh() , exists() , getSource() , findTemplate() . I could then test that by dropping a template at app/Resources/views/themes/standard/pagelayout.html.twig , after clearing cache, my custom template was used instead of the one from EzPublishCoreBundle .
          Hide
          Bertrand Dunogier added a comment -

          I have further tested on the admin:

          • defined the admin design as using ["admin", "standard'] as themes
          • defined the admin siteaccess as using the admin design
          • checked in the Twig debug panel that the admin templates were used from the @ezdesign namespace
          • dropped a copy of vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/public/views/layout.html.twig into app/Resources/views
          • cleared caches
          • checked that the layout from app/Resources was used instead of the one from ezplatform-admin-ui
          Show
          Bertrand Dunogier added a comment - I have further tested on the admin: defined the admin  design as using ["admin", "standard'] as themes defined the admin  siteaccess as using the admin  design checked in the Twig debug panel that the admin templates were used from the @ezdesign namespace dropped a copy of vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/public/views/layout.html.twig into app/Resources/views cleared caches checked that the layout from app/Resources was used instead of the one from ezplatform-admin-ui
          Hide
          Bertrand Dunogier added a comment -

          Merged to EZP-28868.

          Show
          Bertrand Dunogier added a comment - Merged to EZP-28868 .

            People

            • Assignee:
              Unassigned
              Reporter:
              Bertrand Dunogier
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Agile