? Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
25 Jul 2020

Pull Request is the foundation for #30149

Summary of Changes

Introduces Inheritable templates solving numerous problem with the current state of templates. Read more on the linked issue above

This PR is complete in the sense that contains all the changes (even the upgrade path from J3) to introduce the new mode but without introducing the GUI and neither is moving any of the templates to the new mode. These can be done in following PR's

Testing Instructions

Do not try to test this with patch tester, it won't work.
Install the PR's installable, you can d/l it here (at the bottom of this page)
If you want to use git command lines or the desktop app make sure that you'll do a fresh install or apply the updates (sql files)

Make sure you have the browser's console open so you can observe any missing assets.

If this went smooth, then it's a good sign as the installation is a seperate application with it's own template and although this PR is not touching the installation template everything works as before. B/C check 1

Front End step 1

Go to the front end and vist the following urls:

  • /index.php/blog
  • /index.php/blog/3-welcome-to-your-blog
  • /index.php/author-login (login here)
  • /index.php?option=com_config&view=modules&id=109&Itemid=104 (or just try to edit the top left module)

Everything should be fine, no console logs or missinng icons, etc. B/C check 2

Front End step 2

Download this cassiopeia_overrides_v2.zip and extract the contents and copy them in the folder templates/cassiopeia/html. Revisit the pages of the previous step. You should see in the pages some plain text (that will also break a bit the design) Legacy Component view override. You have to look for Component, Module, Plugin and JLayout. If so then the cascading of the templating is working correctly, in the previous step there was no overrides in this one the overrides were treated as top priority. Also cassiopeia has some overrides for the static assets so that was already tested (if you want you might open a normal 4.0 version in another winndow and check the number of assets per page between the 2). B/C check 3

Front End step 3

Install the first new mode template (basically cassiopeia with another name: siteparent) from here siteparent_v2.zip

Go to the admin and make the siteparent template default and also assign all the menus to this template!!! Go to the front end and repeat the Front End step 1 and confirm that everything is as before. check 4

Front End step 4

Go with your filemanager to templates/siteparent and copy the contents os the folder xhtml to the folder html. Redo the ritual of Front End step 1 and confirm that all the parts Component, Module, Plugin and JLayout are there. check 5

Front End step 5

Although the child templates should be created inside joomla's env for testing purposes we will do it using the installer, so install this: sitechild_v2.zip

Go to the admin and make the sitechild template default and also assign all the menus to this template!!! Go to the front end and repeat the Front End step 1 and confirm that everything is as before. check 6

Front End step 6

Go with your filemanager to templates/sitechild and rename the folder xhtml to html. Redo the ritual of Front End step 1 and confirm that all the parts Component, Module, Plugin and JLayout are there. check 7

Back End step 1

Go to the addinistrator end and vist the following urls:

  • /administrator/index.php
  • /administrator/index.php?option=com_content&view=articles
  • /administrator/index.php?option=com_installer&view=install

Everything should be fine, no console logs or missinng icons, etc. B/C check 8

Back End step 2

Download this atum_overrides_v2.zip and extract the contents and copy them in the folder administrator/templates/atum/html. Revisit the pages of the previous step. You should see in the pages some plain text (that will also break a bit the design) Legacy Component view override. You have to look for Component, Module, Plugin and JLayout. If so then the cascading of the templating is working correctly, in the previous step there was no overrides in this one the overrides were treated as top priority. Also cassiopeia has some overrides for the static assets so that was already tested (if you want you might open a normal 4.0 version in another window and check the number of assets per page between the 2). B/C check 9

Back End step 3

Install the new mode template (basically atum with another name: adminparent) from here
adminparent_v2.zip

Go to the administrator template styles and make the adminparent template the default one. Repeat the Back End step 1 and confirm that everything is as before. check 10

Back End step 4

Go with your filemanager to administrator/templates/adminparent and copy the contents os the folder xhtml to the folder html. Redo the dance of the Back End step 1 and confirm that all the parts Component, Module, Plugin and JLayout are there. check 11

Back End step 5

Althouth the child templates should be created inside joomla's env for testing purposes we will do it using the installer, so install this:
adminchild_v2.zip

Go to the admin and make the adminchild template the default. Repeat the Back End step 1 and confirm that everything is as before. check 12

Back End step 6

Go with your filemanager to administrator/templates/adminchild and rename the folder xhtml to html. Redo the ritual of the Back End step 1 and confirm that all the parts Component, Module, Plugin and JLayout are there. check 13

Final checks

Check your db and the table template_styles, you should have

  • autum and cassiopeia with parent 0 and inherits ``
  • from the new ones the parent ones with parent 1 and inherits ``
  • and the child ones ones with parent 0 and inherits siteparent and siteadmin respectfully

Finally someone needs to confirm that the update sql files are all that is needed here

And the last one

You have probably saw some missing strings when you were trying to edit any of the template styles. This is expected as I forgot to include any languages in the parent template, but this is quite easy to check. You are already in the adminchild template so all you have to do is create a folder language/en-GB in the adminparent template and then copy the tmpl_atum*.ini to this folder and rename them to tmpl_adminparent.ini and tmpl_adminparent.sys.ini. Check again the strings are back. Then make the adminparent the default template and check for any changes (readable text should remain readable). You can repeat this for the front end templates (although the function is common for both).

Documentation Changes Required

For the devs the new parts are 2:

  • manifest requires a tag <inheritable>1</inheritable > to enable a template in the new mode
  • all static assets and also any static asset override should be done in the media/( administrator || site )/templateName. Folders like css/js/images inside the above path will act exactly the same as they did in the old templates/name/( css || js || images )
avatar dgrammatiko dgrammatiko - open - 25 Jul 2020
avatar dgrammatiko dgrammatiko - change - 25 Jul 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Jul 2020
Category SQL Administration com_admin Postgresql Installation Libraries
avatar dgrammatiko dgrammatiko - change - 25 Jul 2020
Labels Added: ?
f210d8b 25 Jul 2020 avatar dgrammatiko CS
avatar dgrammatiko dgrammatiko - change - 25 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 25 Jul 2020
avatar kawshar
kawshar - comment - 26 Jul 2020

My recommendation, please keep the database out of it. Just a normal override option would be great. I don't know why Joomla has deep integration with the database for all possible features except the most important Media Manager.

Thanks

a210661 26 Jul 2020 avatar dgrammatiko typo
avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

My recommendation, please keep the database out of it

One way or another the db is involved here as it holds the style data

I don't know why Joomla has deep integration with the database

Very short answer: db is the only secure storage it got. Just don't ask me why the template style details (or any such data) needs any elevated security ?

avatar Fedik
Fedik - comment - 26 Jul 2020

Couple 2 note :)

First note.
I am not strong in English, but for me the property name inherits is a bit of controversial (Usually it means the children inherit parent.)

In current usage I would call it style_template, so the template style object will have 2 property:
Existing template the name of folder for parent template
New style_template the name of folder for override (for child template).

Second note.
I am not very understood why need parent property.
I think if the template has empty inherits it is parent automatically, or maybe I missed something?

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

I am not very understood why need parent property.
Check these lines in the HTMLHelper:

				$templaPath = JPATH_THEMES;

 				if ($template->parent || !empty($template->inherits))
 				{
 					$client     = $app->isClient('administrator') === true ? 'administrator' : 'site';
 					$templaPath = JPATH_ROOT . "/media/templates/$client";
 				}

Basically it's a switch for the new mode, the static files exist in the media/template/( administrator || site )/templateName. It can't be done with only the inherits value because then will not cover the parent template (or it can be done but I'm not that clever ?)

I am not strong in English, but for me the property name inherits is a bit of controversial

Inherits imply inherits from ..., that's why I picked it but naming is hard so anything else can go there, I don't have strong feelings for this

avatar Fedik
Fedik - comment - 26 Jul 2020

Basically it's a switch for the new mode, the static files exist in the media/template/( administrator || site )/templateName

I see now.
For switching we can just check if the folder exists, then do switch, something like:

$template = $app->getTemplate(true);
$templatePath = JPATH_THEMES;
$client = $app->isClient('administrator') === true ? 'administrator' : 'site';

if (is_dir(JPATH_ROOT . "/media/templates/$client/{$template->template}"))
{
	$templaPath = JPATH_ROOT . "/media/templates/$client";
}

So if original (parent) template has the styles/scripts in /media/templates, then HTMLHelper will take it

Inherits imply inherits from ...,

Exactly this part is confusing me ?
I read it like MyStyle inherits from Atum/Cassiopeia folder, but in the implementation it like MyStyle inherits from MyStyle folder,

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

For switching we can just check if the folder exists, then do switch, something like:

This is true we could have eliminated the parent attribute both from the db and the manifest but I'm against it I mean stretching the code you could make any template inheritable but it will be wrong. Most, current templates use something like this:

	$logo = '<img src="' . $this->baseurl . '/templates/' . $this->template . '/images/logo.svg" class="logo d-inline-block" alt="' . $sitename . '">';

which will fail miserable if you try to make a child from it (the $this->baseurl for the child will be a for the parent will be b, file not found will be the result)
Parent templates should always use the API for css,js,images like:

$logo = HTMLHelper::image('logo.svg', '', ['class' => 'logo d-inline-block'], true, 0);

in order to not break their children...

read it like MyStyle inherits from Atum/Cassiopeia folder, but in the implementation it like MyStyle inherits from MyStyle folder

Are you referring to the db names or the php ones?
I might be answering the wrong questions here ?

avatar Fedik
Fedik - comment - 26 Jul 2020

Are you referring to the db names or the php ones?

To both :)

$template  =  $app->getTemplate(true);

var_dump($template->inherits); 
//   ^^^^^^^^^
// This part, I expect it like: $template inherits from "inherits value". 
// But "inherits value" contain "own folder name"

Well, nevermind, maybe it just me.

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

But "inherits value" contain "own folder name"

Maybe I misunderstood you comment in the other PR:

So templateDetails.xml should contain <inherits>parent_name</inherits> (or <parent_name>{blabla}</parent_name>) instead of style_id
avatar Fedik
Fedik - comment - 26 Jul 2020

I'm against it I mean stretching the code you could make any template inheritable but it will be wrong

I think that okay. Sure, it will not work for hard-coded paths, that is not our problem.

avatar Fedik
Fedik - comment - 26 Jul 2020

Maybe I misunderstood you comment in the other PR: <inherits>parent_name</inherits>

Yeah, I meant like this:
User create override called foobar that inherits cassiopeia, so dummy xml contain:

<name>foobar</name>
<inherits>cassiopeia</inherits>

Sorry for confusing :)

UPD: But I forgot that the template_styles table already contain template column, that holds the name of the parent template.

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

@Fedik how about instead of parent we use inheritable (means can have children) and instead of inherits we use parent where parent is just the parent template name?

@brianteeman any suggestions here?

avatar Fedik
Fedik - comment - 26 Jul 2020

how about instead of parent we use inheritable (means can have children) and instead of inherits we use parent where parent is just the parent template name?

That sounds good.

To be sure I right understood:

The dummy xml of child template will have something like:

<name>foobar</name>
<parent>cassiopeia</parent>

<name>foobar</name> will go to style_template column of database;
<parent>cassiopeia</parent> will go to template column of database;
and because we have a parent this will set inheritable = 0 in database

And parent template will have <inheritable>1</inheritable>

I am understood correctly? :)

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

Yup, you got it right. The pain is that I have to redo all the parent/child templates for the tests ?

avatar dgrammatiko dgrammatiko - change - 26 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 26 Jul 2020
avatar Septdir
Septdir - comment - 26 Jul 2020

Child themes are a great idea.
But I have one thing that confuses me.
<inherits> siteparent </inherits>

Usually child themes do not require their own manifest, but the name of the child theme directory indicates the link with the parent.

In the case of an example. The name of the child theme must be siteparent_sitechild, otherwise, to determine where is the parent and where is the child, you will have to look at the manifest of each template.

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

Usually child themes do not require their own manifest, but the name of the child theme directory indicates the link with the parent.

Technically a child template is an actual template but only with one file the manifest (templateDetails.xml). This way there are very few changes that need to be done in the core. Can it be done with a snake case naming? Well it's just code so it can be done but will bee extremely inefficient as you will end up scanning the templates dir and checking each folder. Now the data is coming from the db which one way or another Joomla is using it atm and has exactly 0 performance impact. Also it's not just to get something working in the core you have to think/see what's the code in com_templates. With the proposed approach the changes are minimal.

avatar Septdir
Septdir - comment - 26 Jul 2020

Technically a child template is an actual template but only with one file the manifest (templateDetails.xml). This way there are very few changes that need to be done in the core.

I recently did this for the yootheme template, I had to override a couple of classes.
The child template itself is selected in the parent's settings.

One way or another, I would still add a naming rule for the child template.
You can check during installation.

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

One way or another, I would still add a naming rule for the child template.

That's possible, eg prefix it with the parent name like parentName_childName but it's something that will be done in the com_templates and won't affect anything here

avatar Septdir
Septdir - comment - 26 Jul 2020

That's possible, eg prefix it with the parent name like parentName_childName but it's something that will be done in the com_templates and won't affect anything here

In the future, it will be possible to make a tree display.

But it is more necessary for developers to name their child templates correctly.

avatar dgrammatiko
dgrammatiko - comment - 26 Jul 2020

@Septdir by reviewing the code is this something that breaks yootheme templates? Is this something that will be useful for you/yootheme?

avatar Septdir
Septdir - comment - 26 Jul 2020

@Septdir by reviewing the code is this something that breaks yootheme templates? Is this something that will be useful for you/yootheme?

I haven't reviewed your PR code yet, and I don't think this will be a problem for YOOtheme.
In fact, you added what was missing to the core. This will be very useful, and most importantly, hello to the standardization that many developers are implementing.

My hack for YOOtheme template looks like this
https://github.com/SeptdirWorkshop/jYProExtra/blob/master/jyproextra.php#L191
And I would love to get rid of it in J4

avatar dgrammatiko dgrammatiko - change - 26 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 26 Jul 2020
avatar dgrammatiko dgrammatiko - change - 26 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 26 Jul 2020
avatar dgrammatiko dgrammatiko - change - 26 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 26 Jul 2020
e7e9b0e 26 Jul 2020 avatar dgrammatiko CS
avatar dgrammatiko dgrammatiko - change - 27 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 27 Jul 2020
avatar dgrammatiko dgrammatiko - change - 27 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 27 Jul 2020
avatar dgrammatiko dgrammatiko - change - 27 Jul 2020
The description was changed
avatar dgrammatiko dgrammatiko - edited - 27 Jul 2020
3573ec4 27 Jul 2020 avatar dgrammatiko oops
avatar dgrammatiko
dgrammatiko - comment - 29 Jul 2020

@wilsonge any signal will be good here

avatar HLeithner
HLeithner - comment - 29 Jul 2020

We are in feature freeze for j4.0

avatar dgrammatiko
dgrammatiko - comment - 29 Jul 2020

@HLeithner so then I will close this one?

avatar dgrammatiko dgrammatiko - change - 29 Jul 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-07-29 18:15:25
Closed_By dgrammatiko
avatar dgrammatiko dgrammatiko - close - 29 Jul 2020
avatar HLeithner
HLeithner - comment - 29 Jul 2020

@dgrammatiko that was not my intention, it's more that we should focus on bugfixing and target new feature on 4.1 branch.

I would like to give a proper feedback on this feature too, but didn't had the time to look at the pr .

At a first glance I'm a bit confused about some decisions you made.

  1. why do we need the database entry? or better why do we need both?
  2. wouldn't it better to introduce a completely new "siteowner override concept", I didn't thought much about it but it's not only the template you may want to extend other parts of the cms like plugins or libraries (don't know if useful).
  3. Did I saw right that you only can not have a chain of templates? base template -> company template -> site template. for example piwigo has exactly this type of template engine.
  4. I'm a bit concerned about performance, every database query and every file exists check costs server resources
avatar dgrammatiko
dgrammatiko - comment - 29 Jul 2020
  1. wouldn't it better to introduce a completely new "siteowner override concept"

I don't know what you mean by that but the child templates actually solve a very real problem: updates! (but not only that)

1,3,4

You have to check what I did here and also step through a bit in the lifecycle. The child template is a real template thus the only extra load is some lookups for layouts and static assets, there is no extra db query. The idea of chain able templates will not work well with Joomla simply because the lookups will grow exponentially per subfolder and thus it will be awfully slow. But you can deal with it in the com_templates (eg presentation).

avatar Fedik
Fedik - comment - 29 Jul 2020

I'm a bit concerned about performance, every database query and every file exists check costs server resources

It is reuse existing template style, so no extra cost

avatar HLeithner
HLeithner - comment - 29 Jul 2020

thanks for the explanation I would like to make some code suggestion, I hope it's ok for you I have reopened the pr.
beside my comments the pr should be rebased on 4.1

avatar HLeithner HLeithner - change - 29 Jul 2020
Status Closed New
Closed_Date 2020-07-29 18:15:25
Closed_By dgrammatiko
avatar HLeithner HLeithner - change - 29 Jul 2020
Status New Pending
avatar HLeithner HLeithner - reopen - 29 Jul 2020
avatar bonzani bonzani - test_item - 31 Jul 2020 - Tested successfully
avatar bonzani
bonzani - comment - 31 Jul 2020

I have tested this item successfully on eec9d9a

One of the most useful things in J4 I've seen so far...


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30192.

avatar wilsonge wilsonge - close - 9 Aug 2020
avatar wilsonge wilsonge - merge - 9 Aug 2020
avatar wilsonge wilsonge - change - 9 Aug 2020
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-08-09 22:47:01
Closed_By wilsonge
avatar wilsonge
wilsonge - comment - 9 Aug 2020

I really really shouldn't be pressing merge here - but I've seen several template clubs in favour of this so I'm going to break my own rules and hope I don't regret it. thankyou for this really nice feature @dgrammatiko

Add a Comment

Login with GitHub to post a comment