? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
23 May 2017

Summary of Changes

With the move to namespaces, we didn't touch the location of the component template files, eg. default.php. They are still in a folder like /components/com_content/views/article/tmpl. This location was valid when we had the view.html.php in the folder above. Now the class is in a different folder. So I think the template files should be moved to a location where it makes more sense and is inline with the rest of the core like modules or plugins.

This pr moves the template files to a tmpl folder within the component root folder below the view name. So /components/com_content/views/article/tmpl/default.php becomes /components/com_content/tmpl/article/default.php.

The menu manager was adopted to support that new folder scheme as well as the view.

This pr was inspired by #15221 and is fully BC as all the other views should render as before. If this pr get accepted, we need to move all the template files of all the namespaced components.

Testing Instructions

  • Open an article in the back end.
  • Create a new menu item with a "Single Article"
  • Create a template override in the template manager for the article view and another one.

Expected result

All should work as before. Also the template overrides should work.

Actual result

Nothing is broken all should work.

Documentation Changes Required

This new location needs to be documented.

avatar laoneo laoneo - open - 23 May 2017
avatar laoneo laoneo - change - 23 May 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 May 2017
Category Administration com_content com_menus Front End Libraries
avatar brianteeman
brianteeman - comment - 23 May 2017

wont the code in com_templates that creates overrides need changing as well?

avatar laoneo laoneo - edited - 23 May 2017
avatar laoneo laoneo - change - 23 May 2017
The description was changed
avatar laoneo
laoneo - comment - 23 May 2017

Nope, overrides are the same.

avatar laoneo laoneo - change - 23 May 2017
The description was changed
avatar laoneo laoneo - edited - 23 May 2017
avatar mbabker
mbabker - comment - 23 May 2017

It would need to know where to look to find the overrides though.

avatar dgt41
dgt41 - comment - 23 May 2017

@mbabker is there any plan to refactor the override creator part?

avatar laoneo
laoneo - comment - 23 May 2017

I'v just tested it and overrides do work as before.

avatar dgt41
dgt41 - comment - 23 May 2017

@laoneo creating an override?

avatar laoneo
laoneo - comment - 23 May 2017

Yes

avatar brianteeman
brianteeman - comment - 23 May 2017

It would need to know where to look to find the overrides though.

how does it know where to look if the files have moved

avatar laoneo
laoneo - comment - 23 May 2017

Why do you guys don't believe me, it works ?

avatar brianteeman
brianteeman - comment - 23 May 2017

@dgt41 that code is for creating the files and folders - i am talking about the code that finds the views that can be overriden

avatar brianteeman
brianteeman - comment - 23 May 2017

thanks @mbabker

avatar brianteeman
brianteeman - comment - 23 May 2017

and reading that code I cant see how it can find a view in the new location - but thats probably my lack of skill at reading code if @laoneo says it does. Anyway this is what I was referring to in my first comment

avatar laoneo
laoneo - comment - 24 May 2017

This change here https://github.com/joomla/joomla-cms/pull/16218/files#diff-c0ed342062e86e3c3f81da894f9d3e8fR137 adds the tmpl path to the file lookup array.

avatar joomdonation
joomdonation - comment - 24 May 2017

@laoneo I think Brian is talking about the code which is used to create override in Template Manager. See the block of code which Michael mentioned https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_templates/models/template.php#L569-L597

Since the layout is now moved to new location, we need to adjust that block of code to allow template manager to find layout from new location

avatar laoneo
laoneo - comment - 24 May 2017

I was thinking I do miss something. Will have a look on that as well.

avatar brianteeman
brianteeman - comment - 24 May 2017

Yes that's exactly what I meant

avatar laoneo laoneo - change - 24 May 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 24 May 2017
Category Administration com_content com_menus Front End Libraries Administration com_content com_menus com_templates Front End Libraries
avatar laoneo
laoneo - comment - 24 May 2017

Changed the override editor to support the new scheme as well. Updated the test instructions.

avatar laoneo laoneo - edited - 24 May 2017
avatar brianteeman
brianteeman - comment - 26 May 2017

I have tested this item ? unsuccessfully on b9b0e6d

creating overrides is not building the path correctly if the site is installed in a subdirectory as it is including the subdirectory that the site is installed in


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

avatar brianteeman brianteeman - test_item - 26 May 2017 - Tested unsuccessfully
avatar brianteeman
brianteeman - comment - 26 May 2017

this screenshot shows an override created before applying this pr at the bottom and after applying this pr at the top. you will see that my site is installed in a subdirectory called cms4

screenshotr10-46-56

avatar laoneo laoneo - change - 27 May 2017
The description was changed
avatar laoneo
laoneo - comment - 27 May 2017

I just tested it and it again and I'm working in a subfolder as well, it worked as it should. For a test can you install it from here https://github.com/Digital-Peak/joomla-cms/archive/j4/move-views-tmpl.zip, just to be sure the full patch get applied.

avatar brianteeman
brianteeman - comment - 27 May 2017

Retested as requested with your zip - no change

screenshotr19-32-19

avatar laoneo
laoneo - comment - 27 May 2017

Perhaps somebody else can test it as I don't know what to do more. Guess we will have another look on the code sprint as well. Thanks so far for testing.

avatar joomdonation
joomdonation - comment - 28 May 2017

I don't see the problem like Brian mentioned, but there are still issues with creating overrider:

  1. For com_users (old layout structure), the override is created at html\view\com_users\views\login . It should be html\com_users\login only

  2. For com_content (new layout structure), the override is created at html\view\com_content\tmpl\article, it should be html\com_content\article only

avatar joomdonation
joomdonation - comment - 28 May 2017

Forgot to mention I am using Windows. And I installed your branch for testing. So something is still not correct yet

avatar brianteeman
brianteeman - comment - 28 May 2017

@joomdonation I am on windows too

avatar joomdonation
joomdonation - comment - 29 May 2017

Also, maybe the code in foreach block of getOverridesList method could be changed to:

foreach ($components as $component)
{
	$requireTmplFolder = true;

	if (file_exists($componentPath . '/' . $component . '/tmpl/'))
	{
		$viewPath = \JPath::clean($componentPath . '/' . $component . '/tmpl/');
		$requireTmplFolder = false;
	}
	elseif (file_exists($componentPath . '/' . $component . '/views/'))
	{
		$viewPath = \JPath::clean($componentPath . '/' . $component . '/views/');
	}
	elseif (file_exists($componentPath . '/' . $component . '/view/'))
	{
		$viewPath = \JPath::clean($componentPath . '/' . $component . '/view/');
	}
	else
	{
		$viewPath = '';
	}
	
	if ($viewPath)
	{
		$views = \JFolder::folders($viewPath);

		foreach ($views as $view)
		{
			// Only show the view has layout inside it
			if (!$requireTmplFolder || file_exists($viewPath . $view . '/tmpl'))
			{
				$result['components'][$component][] = $this->getOverridesFolder($view, $viewPath);
			}
		}
	}
}

I think it is less change, easier to understand (maybe just me) and save \JFolder::folders call on unnecessary folders.

avatar brianteeman
brianteeman - comment - 29 May 2017

the override creation works for me now


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

avatar laoneo
laoneo - comment - 29 May 2017

Good to hear

avatar wilsonge wilsonge - change - 29 May 2017
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-05-29 09:29:31
Closed_By wilsonge
avatar wilsonge wilsonge - close - 29 May 2017
avatar wilsonge wilsonge - merge - 29 May 2017
avatar wilsonge
wilsonge - comment - 29 May 2017

Seems good to me. Let's get the rest of the core component converted :)

Add a Comment

Login with GitHub to post a comment