User tests: Successful: Unsuccessful:
At the moment it's very complicated to define a default sublayout which can be loaded by different layouts. For example let's assume you have a calendar view with three layouts: month, week, year and the following structure
|- views
|- calendar
|- tmpl
|- month.php
|- week.php
|- year.php
|- year_myfunnystuff.php
I can call the three layouts with the parameter &view=calendar&layout=week/month/year. But now if I want to load "myfunnystuff" in all other layouts I have to do the following:
year: $this->loadTemplate('myfunnystuff');
month: $this->setLayout('year');$this->loadTemplate('myfunnystuff');$this->setLayout('month');
week: $this->setLayout('year');$this->loadTemplate('myfunnystuff');$this->setLayout('week');
After this patch it's much more easier:
year: $this->loadTemplate('myfunnystuff');
month: $this->loadTemplate('myfunnystuff', 'year');
week: $this->loadTemplate('myfunnystuff', 'year');
try to create structures like above and load it.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
So there is no need for this PR and it can be closed?
That's actually very useful and shouldn't be closed.
@Bakual this pr solves a different use case. The issue is when you want to use a sublayout of a different layout, then you need to do the hack @bembelimen has described in the description or you need to copy it. You can even go further and load one template in another with this patch.
The PR description starts with:
At the moment it's very complicated to define a default sublayout which can be loaded by different layouts.
Just name the default sublaout default_foo
and it will work. That's exactly the usecase for that feature that already exists.
The issue is when you want to use a sublayout of a different layout
That would be a different usecase, and honestly I'd say it's a hack if you call a sublayout from another layout. Just name that sublayout with a prefix "default_" if you're going to use it in multiple layouts.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-07-23 11:52:24 |
Closed_By | ⇒ | bembelimen |
I have tested this item
@fatmaakay thanks for testing but this PR is closed.
@fatmaakay could you please test here: #21228
If you name your sublayout
default_myfunnystuff.php
, you can load it using `$this->loadTemplate('myfunnystuff') from any layout. The function has a fallback to "default_" prefix in case a layout specifc file (eg year_myfunnystuff.php) doesn't exist.