-
-
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
Joomla 4.3.3 Alternate Layouts don't work when there is a subline in the template #41270
Comments
As far as I know this is expected behaviour, and it was always like that. There might be even some tooltip in the template name field telling that only alpha-numeric characters and dashes are allowed. If someone else confirms this (I don't expect myself to be perfect), I will close this issue as expected behaviour. |
@brianteeman ok so the issue is not coming from the underscore? Strange :-/ |
silly question but in html/com_content/category/mylayout.php did you update the loadTemplate for your new names |
It can NOT come from the underscore because that is how child templates are created by joomla |
yes I did - the error dissapears when I move the complete structure |
well its something in your code and not a core issue |
Not in my code but maybe some exception for not child template templates with underscore - i will investigate further |
@brianteeman and @richard67 thanks for testing - I will report back what the issue was. |
@coolcat-creations if you make a template override for any default and call it mylayout.php
it will load mylayout_item.php if yo did not override this statement to make
|
@chmst thats what I wrote #41270 (comment) |
@brianteeman @chmst I wrote both correctly in the layout. As said it works as indented when I move it in another template. there must be something else interfering. I am investigating further. |
I just repeated it from scratch with no problem at all |
I just tested with a not template and named it test_test and it worked too. So the issue is not in the core but something in the maintemplate probably. Thank you all for testing. |
The problem is because the child template folder name begins with the same name as the template (e.g. cassiopeia and cassiopeia_child). Here is a fix for it in // Change the template folder if alternative layout is in different template
if (isset($layoutTemplate) && $layoutTemplate !== '_' && $layoutTemplate != $template->template) {
$this->_path['template'] = str_replace(
JPATH_THEMES . DIRECTORY_SEPARATOR . $template->template . DIRECTORY_SEPARATOR,
JPATH_THEMES . DIRECTORY_SEPARATOR . $layoutTemplate . DIRECTORY_SEPARATOR,
$this->_path['template']
);
} |
so why is it working perfectly for me (and others) |
This depends on how many subtemplates are loaded, therefore the HtmlView::loadTemplate() method is called multiple times. $this->subtemplatename = 'myarticles';
echo LayoutHelper::render('joomla.content.category_default', $this); |
Fix like suggested in joomla#41270 (comment)
Should be closed as there is a PR |
please test #41274 |
Fix like suggested in #41270 (comment)
Steps to reproduce the issue
have a template named yourtemplate_child
make a copy of
html/com_content/category/default.php
html/com_content/category/default.xml
html/com_content/category/default_articles.php
html/com_content/category/default_children.php
rename them and put in this template an alternate layout for a category list:
html/com_content/category/mylayout.php
html/com_content/category/mylayout.xml
html/com_content/category/mylayout_myarticles.php
html/com_content/category/mylayout_mychildren.php
In mylayout.php change articles to myarticles (I did that but did not mentio in the test instructions)
Change something in the _myarticles file or put a die(); at the top to see if your template is loaded.
Change the layout title in the mylayout.xml so you recognize it in the menu item types overview
Create a new menu item and select my layout as a menu item type
Expected result
your alternate layout is loaded when you selected it as a menu type
Actual result
Several issues here:
so a step in between would be to create a file named:
/templates/yourtemplate/html/layouts/joomla/content/category_mylayout.php
and rename also the subtemplates in the $displayData->loadTemplate call
But even if you do this - you will get a 500 Error when your template has an underscore in it.
If you move the whole structure to a template without underscore it works.
System information (as much as possible)
I tried to debug within the libraries/src/MVC/View/HtmlView.php file and when I print out the path Joomla is looking for I get:
mytemplate_nlh_nlh_nlh/html/
altough my templates name is only mytemplatee_nlh, so I think it has something to do with the underscores in the template name.
The text was updated successfully, but these errors were encountered: