-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[4.0] Child templates #30192
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] Child templates #30192
Changes from all commits
9baf09c
7eb0c83
f210d8b
9c8ec53
a210661
bf7fd52
cda7686
7d8e760
e7e9b0e
32302d5
428ec11
788d674
7e97cc8
6cf49fc
55bdd41
3d20ace
0b4df24
3573ec4
a3603ca
750fb26
eec9d9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ALTER TABLE `#__template_styles` ADD COLUMN `inheritable` tinyint(1) NOT NULL DEFAULT 0; | ||
| ALTER TABLE `#__template_styles` ADD COLUMN `parent` varchar(50) DEFAULT ''; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ALTER TABLE "#__template_styles" ADD COLUMN "inheritable" smallint NOT NULL DEFAULT 0; | ||
| ALTER TABLE "#__template_styles" ADD COLUMN "parent" varchar(50) DEFAULT ""; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -798,6 +798,8 @@ CREATE TABLE IF NOT EXISTS "#__template_styles" ( | |
| "client_id" smallint DEFAULT 0 NOT NULL, | ||
| "home" varchar(7) DEFAULT '0' NOT NULL, | ||
| "title" varchar(255) DEFAULT '' NOT NULL, | ||
| `inheritable` smallint DEFAULT 0 NOT NULL, | ||
| `parent` varchar(50) DEFAULT '', | ||
|
Comment on lines
+801
to
+802
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange that nobody saw this and nobody tested with PostgreSQL like it should always be done when a PR has database changes. This has broken installation on PostgreSQL. Will prepare a fix.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wong names quotes I mean.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed with #30327 . |
||
| "params" text NOT NULL, | ||
| PRIMARY KEY ("id") | ||
| ); | ||
|
|
@@ -808,10 +810,9 @@ CREATE INDEX "#__template_styles_idx_client_id_home" ON "#__template_styles" ("c | |
| -- | ||
| -- Dumping data for table `#__template_styles` | ||
| -- | ||
|
|
||
| INSERT INTO "#__template_styles" ("id", "template", "client_id", "home", "title", "params") VALUES | ||
| (10, 'atum', 1, '1', 'atum - Default', ''), | ||
| (11, 'cassiopeia', 0, '1', 'cassiopeia - Default', '{"logoFile":"","fluidContainer":"0","sidebarLeftWidth":"3","sidebarRightWidth":"3"}'); | ||
| INSERT INTO "#__template_styles" ("id", "template", "client_id", "home", "title", "inheritable", "parent", "params") VALUES | ||
| (10, 'atum', 1, '1', 'atum - Default', 0, '', ''), | ||
| (11, 'cassiopeia', 0, '1', 'cassiopeia - Default', 0, '', '{"logoFile":"","fluidContainer":"0","sidebarLeftWidth":"3","sidebarRightWidth":"3"}'); | ||
|
|
||
| SELECT setval('#__template_styles_id_seq', 12, false); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -176,6 +176,11 @@ public function dispatch($component = null) | |||||||||||||||||||||||||||||||||||||
| $wr->addExtensionRegistryFile($component); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if ($template->parent) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| $wr->addTemplateRegistryFile($template->parent, $this->getClientId()); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| $wr->addTemplateRegistryFile($template->template, $this->getClientId()); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -394,7 +399,17 @@ public function getTemplate($params = false) | |||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if (\is_object($this->template)) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if (!file_exists(JPATH_THEMES . '/' . $this->template->template . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| if ($this->template->parent) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if (!file_exists(JPATH_THEMES . '/' . $this->template->template . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if (!file_exists(JPATH_THEMES . '/' . $this->template->parent . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| throw new \InvalidArgumentException(Text::sprintf('JERROR_COULD_NOT_FIND_TEMPLATE', $this->template->template)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| elseif (!file_exists(JPATH_THEMES . '/' . $this->template->template . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+402
to
+412
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @HLeithner the rest of the changes are fine but not this one. You can reduce the inner 2 conditionals to 1 but changing it to 1 (top) conditional is wrong in the sense that the !file_exists(JPATH_THEMES . '/' . $this->template->template . '/index.php')
&& (
empty($this->template->parent)
|| !file_exists(JPATH_THEMES . '/' . $this->template->parent . '/index.php')
)introduces 2 more file lookups for every execution for no reason.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
actually not true, the second but that was not the point you can leave it that way if you want it's only to reduce duplicated code. Will you merge the other suggestions?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, although I have to state that I'm not so sure I want to move this one forward anymore.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason? because I said it can not go into 4.1?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read them but the explanation but they don't make sense to me, a js that's template independent is something different then a image that's only used in the template. We already split everything about the joomla filesystem at least the templates are "self contained" but that's only my opinion.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The move to If you want to move assets to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You really don’t get it. It’s you only opportunity to fix this and bring consistency...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do a PR where you only move the assets to media. I actually think that could still be done for 4.0 as it's not a new feature.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guys do you even realise the amount of work I put here to create all the 4 templates and the other html overrides for the tests? Asking to break it in 2 is just asking me to repeat the whole work twice. Why? This is a new mode, it doesn't and shouldn't affect any of the current templates |
||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| throw new \InvalidArgumentException(Text::sprintf('JERROR_COULD_NOT_FIND_TEMPLATE', $this->template->template)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -453,8 +468,9 @@ public function getTemplate($params = false) | |||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| // Load styles | ||||||||||||||||||||||||||||||||||||||
| $db = Factory::getDbo(); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| $query = $db->getQuery(true) | ||||||||||||||||||||||||||||||||||||||
| ->select($db->quoteName(['id', 'home', 'template', 's.params'])) | ||||||||||||||||||||||||||||||||||||||
| ->select($db->quoteName(['id', 'home', 'template', 's.params', 'inheritable', 'parent'])) | ||||||||||||||||||||||||||||||||||||||
| ->from($db->quoteName('#__template_styles', 's')) | ||||||||||||||||||||||||||||||||||||||
| ->where( | ||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -529,7 +545,35 @@ public function getTemplate($params = false) | |||||||||||||||||||||||||||||||||||||
| $template->template = InputFilter::getInstance()->clean($template->template, 'cmd'); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Fallback template | ||||||||||||||||||||||||||||||||||||||
| if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| if (!empty($template->parent)) | ||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can simplify this too like them above to reduce code duplication |
||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if (!file_exists(JPATH_THEMES . '/' . $template->parent . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| $this->enqueueMessage(Text::_('JERROR_ALERTNOTEMPLATE'), 'error'); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Try to find data for 'cassiopeia' template | ||||||||||||||||||||||||||||||||||||||
| $original_tmpl = $template->template; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| foreach ($templates as $tmpl) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| if ($tmpl->template === 'cassiopeia') | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| $template = $tmpl; | ||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Check, the data were found and if template really exists | ||||||||||||||||||||||||||||||||||||||
| if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| throw new \InvalidArgumentException(Text::sprintf('JERROR_COULD_NOT_FIND_TEMPLATE', $original_tmpl)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| elseif (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php')) | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| $this->enqueueMessage(Text::_('JERROR_ALERTNOTEMPLATE'), 'error'); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -751,6 +795,9 @@ protected function render() | |||||||||||||||||||||||||||||||||||||
| $this->set('themeFile', $file . '.php'); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Pass the parent template to the state | ||||||||||||||||||||||||||||||||||||||
| $this->set('themeInherits', $template->parent); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
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.
Next mistake
DEFAULT ""should beDEFAULT ''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.
please submit a fix i'll test it
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.
Done #30330 .