-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0] Move template files to tmpl folder #16218
Conversation
wont the code in com_templates that creates overrides need changing as well? |
Nope, overrides are the same. |
It would need to know where to look to find the overrides though. |
@mbabker is there any plan to refactor the override creator part? |
I'v just tested it and overrides do work as before. |
@laoneo creating an override? |
Yes |
how does it know where to look if the files have moved |
@brianteeman everything happens here: So yes it should work as is |
Why do you guys don't believe me, it works 😩 |
@dgt41 that code is for creating the files and folders - i am talking about the code that finds the views that can be overriden |
thanks @mbabker |
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 |
This change here https://github.com/joomla/joomla-cms/pull/16218/files#diff-c0ed342062e86e3c3f81da894f9d3e8fR137 adds the tmpl path to the file lookup array. |
@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 |
I was thinking I do miss something. Will have a look on that as well. |
Yes that's exactly what I meant |
Changed the override editor to support the new scheme as well. Updated the test instructions. |
I have tested this item 🔴 unsuccessfully on b9b0e6d This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16218. |
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. |
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. |
I don't see the problem like Brian mentioned, but there are still issues with creating overrider:
|
Forgot to mention I am using Windows. And I installed your branch for testing. So something is still not correct yet |
@joomdonation I am on windows too |
} | ||
|
||
$result['components'][$component][] = $this->getOverridesFolder($view, $folder . '/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this line to
$result['components'][$component][] = $this->getOverridesFolder($view, \JPath::clean($folder . '/'));
fixed the problem which I reported (on windows)
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. |
the override creation works for me now This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16218. |
Good to hear |
Seems good to me. Let's get the rest of the core component converted :) |
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
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.