PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
17 Aug 2023

Summary of Changes

There are different ways for form fields, plugins and modules to render their layout files. This should be unified and all parts should use FileLayout to render the layouts.

Testing Instructions

  • Enable the stats plugin
  • Enable the voting plugin
  • Open the article form in the back end and create an article
  • Set show voting to yes in the article options
  • Make sure that the breadcrumbs plugin is enabled
  • Open an article on the front

Actual result BEFORE applying this Pull Request

Stats are displayed, the article form throws no error and the voting feature is displayed in the article details view.

Expected result AFTER applying this Pull Request

Stats are displayed, the article form throws no error and the voting feature is displayed in the article details view.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

dbd1b72 17 Aug 2023 avatar laoneo more
5937fd2 17 Aug 2023 avatar laoneo test
avatar joomla-cms-bot joomla-cms-bot - change - 17 Aug 2023
Category Layout Libraries Modules Front End Plugins Unit Tests
avatar laoneo laoneo - open - 17 Aug 2023
avatar laoneo laoneo - change - 17 Aug 2023
Status New Pending
avatar laoneo laoneo - change - 17 Aug 2023
The description was changed
avatar laoneo laoneo - edited - 17 Aug 2023
avatar laoneo laoneo - change - 17 Aug 2023
Title
Unify the rendering of plugins, form fields and modules
[5.0] Unify the rendering of plugins, form fields and modules
avatar laoneo laoneo - edited - 17 Aug 2023
6c06cfc 17 Aug 2023 avatar laoneo cs
avatar laoneo laoneo - change - 17 Aug 2023
Labels Added: ? PR-5.0-dev
avatar Fedik
Fedik - comment - 18 Aug 2023

Sorry, I do not like what is going on here. It a no no. I will write more, later.

avatar laoneo laoneo - change - 18 Aug 2023
Title
[5.0] Unify the rendering of plugins, form fields and modules
[RFC] [5.0] Unify the rendering of plugins, form fields and modules
avatar laoneo laoneo - edited - 18 Aug 2023
avatar laoneo
laoneo - comment - 18 Aug 2023

@Fedik wait, this will probably completely rewritten.

b7ecf4b 18 Aug 2023 avatar laoneo trait
avatar joomla-cms-bot joomla-cms-bot - change - 18 Aug 2023
Category Layout Libraries Modules Front End Plugins Unit Tests Layout Libraries Front End Plugins
avatar laoneo laoneo - change - 18 Aug 2023
Labels Added: ?
avatar laoneo laoneo - change - 18 Aug 2023
Labels Removed: ?
7c5077a 18 Aug 2023 avatar laoneo docs
avatar laoneo laoneo - change - 18 Aug 2023
The description was changed
avatar laoneo laoneo - edited - 18 Aug 2023
avatar laoneo laoneo - change - 18 Aug 2023
Title
[RFC] [5.0] Unify the rendering of plugins, form fields and modules
[5.0] Unify the rendering of plugins, form fields and modules
avatar laoneo laoneo - edited - 18 Aug 2023
avatar laoneo laoneo - change - 18 Aug 2023
Labels Removed: ?
5f5bd80 18 Aug 2023 avatar laoneo bc
4a904f3 18 Aug 2023 avatar laoneo forms
avatar Fedik
Fedik - comment - 19 Aug 2023

I see what you trying to do. And I am not sure if it good or bad.


Currently we have 2 kind of rendering path: tmpl layout and layouts layout. As following:

tmpl layouts:

PluginHelper::getLayoutPath (for default):
  templates/templateName/html/plg_foo_bar/tmpl/default.php
  plugins/foo/bar/tmpl/default.php

ModuleHelper::getLayoutPath (for default):
  templates/templateName/html/mod_foobar/tmpl/default.php
  modules/mod_foobar/tmpl/default.php

HtmlView::loadTemplate: template view/tmpl => component/view/tmpl

tmpl sublayout:

Sublayout will look for: default_sublayout.php

layouts:

FileLayout (for foo.bar):
 ..componentName/layouts/foo/bar.php
 ..templateName/html/layouts/foo/bar.php
 layouts/foo/bar.php

layouts sublayout:

Sublayout will look for: ...layouts/foo/bar/sublayout.php

I am not sure if it a good idea of merging them (as you doing in PR), and use FileLayout for lookup of tmpl/ layout.
Maybe we have to migrate module/plugins to layouts/? Or does it makes no sense?

Also maybe we can create a layout class for each extension (if we decide to migrate to layouts/):

// Modules
class ModuleLayout extends FileLayout{}
// Plugins
class PluginLayout extends FileLayout{}

Each will have own method getDefaultIncludePaths()


About LayoutRendererTrait:
I would keep it simplier, just one method:

function getRenderer(string $layout, array $options = []): FileLayout {}
// or
function getLayoutRenderer(string $layout, array $options = []): FileLayout {}

and remove render(), isDebugEnabled(), getLayoutIncludePaths(), this can be set in getRenderer(), or with $options.


Would be good to hear other opinios about the topic.

avatar dgrammatiko
dgrammatiko - comment - 19 Aug 2023

Maybe we have to migrate module/plugins to layouts/? Or does it makes no sense?

That was one goal for Joomla v4 but we never accomplished it. @wilsonge can confirm this.

The parts about sublayouts are totally valid (but I haven't play around with the code to see if there's a (not over engineered) way around it).

FWIW I was always in favour of having one and only one template/layout/(call it whatever you want) system.

avatar laoneo
laoneo - comment - 21 Aug 2023

Thanks @Fedik for your input, really appreciated.

Maybe we have to migrate module/plugins to layouts/?

I would leave it as files in tmpl/ are meant to have a real world usage while the ones in layout/ are mainly used in files in tmpl/. So like that we have a clear distinction. Now the question arises if we really should use the rendering engine of layouts/ for tmpl/ files.

Also maybe we can create a layout class for each extension

In which namespace would you put the ModuleLayout and PluginLayout classes? I would leave it but can change if others prefer extra classes.

I would keep it simpler, just one method:

If we have extra classes, then no method is needed at all.

avatar Fedik
Fedik - comment - 21 Aug 2023

In which namespace would you put the

I think under Joomla\CMS\Layout is fine.

I would leave it as files in tmpl/ are meant to have a real world usage while the ones in layout/ are mainly used in files in tmpl/.

Then name the classes ModuleTmplLayout and PluginTmplLayout. To avoid confusion with regular layouts/, and when in future we will make move to layouts/.

Now the question arises if we really should use the rendering engine of layouts/ for tmpl/ files.

IDK, It just a files lookup, in general. It can work.
Can also be own, but implementing LayoutInterface

avatar HLeithner
HLeithner - comment - 21 Aug 2023

The purpose is to get rid of templates everywhere except components for now. Plugins and modules normally doesn't render full pages only parts of it. Do O would move all tmpl files to layouts in the plugin/modules folder.

I thought about the own plugin and modules classes based on filelayout. It doesn't make usage easy in the future, when we want to inject everything which should be in a layout to render like language, user, route what ever. That can't be abstracted if you use a one line call.

Also I think the trait can be used in 3rd l
Party classes for a sole rendering engine, example I maybe it for PDF rendering.

avatar brianteeman
brianteeman - comment - 21 Aug 2023

That's a pointless pipedream @HLeithner that can't happen for years and years

avatar HLeithner
HLeithner - comment - 21 Aug 2023

I'm talking about modules and Plugins for now which is possible with this PR for modules and Plugins. I know it's not anywhere near for views

avatar Fedik
Fedik - comment - 21 Aug 2023

For plugins/modules, we probably can try make smooth transition,
with extended lookup that doing a check in tmpl/ and then layout/.

Example layout will be: foobar.default
Then new ModuleLayout('foobar.default', null, ['module' => 'foobar']) will do lookop as following:

templates/templateName/html/mod_foobar/tmpl/default.php (template/tmpl)
modules/mod_foobar/tmpl/default.php (module/tmpl)
templates/templateName/html/layouts/modules/foobar/default.php (template/layouts)
layouts/modules/foobar/default.php (layouts)

And the same for plugins.
Maybe I missed some paths, but it is a general idea.
Then, at some point drop support for tmpl/ in module and plugin.

Pretty hacky and maybe over engineered, but can work.

tmpl for component View will stay, it part of View API.

avatar HLeithner
HLeithner - comment - 22 Aug 2023

I'm postpone this for next release, talking about it tomorrow maintainer meeting

avatar HLeithner
HLeithner - comment - 24 Aug 2023

@laoneo yesterdays meeting has to change requests.

  1. Remove the extract part for now, I'm in favor but concerns about conflicts / unexcpected behavior came up we can do this after more investigation in a separated pr.
  2. Move the layouts from the tmpl folder the layouts folder (in the extension folder) and add b/c code to look in the old html folders before the layout folders (and of course deprecate the tmpl folder)

if we use layouts we also should use the file structure of it.

avatar laoneo
laoneo - comment - 1 Sep 2023

Currently I have no time to make it ready for 5.0. Better to do it right for 6.0 then.

avatar laoneo laoneo - close - 1 Sep 2023
avatar laoneo laoneo - change - 1 Sep 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-09-01 11:07:51
Closed_By laoneo

Add a Comment

Login with GitHub to post a comment