diff --git a/administrator/components/com_templates/src/View/Template/HtmlView.php b/administrator/components/com_templates/src/View/Template/HtmlView.php index f0b21dca56f24..b673a2c6614d1 100644 --- a/administrator/components/com_templates/src/View/Template/HtmlView.php +++ b/administrator/components/com_templates/src/View/Template/HtmlView.php @@ -258,7 +258,12 @@ protected function addToolbar() // Add a copy template button elseif ($this->type === 'home') { - ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE'); + $templatesPath = ((int) $this->template->client_id === 1 ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/'; + $templateDetails = $templatesPath . $this->template->name . '/templateDetails.xml'; + $templateXML = simplexml_load_file($templateDetails); + if ((string) $templateXML->namespace === '' || $templateXML->namespace === null) { + ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE'); + } } } diff --git a/libraries/namespacemap.php b/libraries/namespacemap.php index 572a63c85576f..0210ea4d9657c 100644 --- a/libraries/namespacemap.php +++ b/libraries/namespacemap.php @@ -65,6 +65,7 @@ public function create() $extensions = array_merge( $this->getNamespaces('component'), $this->getNamespaces('module'), + $this->getNamespaces('template'), $this->getNamespaces('plugin'), $this->getNamespaces('library') ); @@ -139,7 +140,7 @@ protected function writeNamespaceFile($elements) */ private function getNamespaces(string $type): array { - if (!in_array($type, ['component', 'module', 'plugin', 'library'], true)) + if (!in_array($type, ['component', 'module', 'plugin', 'template', 'library'], true)) { return []; } @@ -153,6 +154,10 @@ private function getNamespaces(string $type): array { $directories = [JPATH_SITE . '/modules', JPATH_ADMINISTRATOR . '/modules']; } + elseif ($type === 'template') + { + $directories = [JPATH_SITE . '/templates', JPATH_ADMINISTRATOR . '/templates']; + } elseif ($type === 'plugin') { $directories = Folder::folders(JPATH_PLUGINS, '.', false, true); @@ -173,6 +178,7 @@ private function getNamespaces(string $type): array // Strip the com_ from the extension name for components $name = str_replace('com_', '', $extension, $count); + $name = $type === 'template' ? 'templateDetails' : $name; $file = $extensionPath . $name . '.xml'; // If there is no manifest file, ignore. If it was a component check if the xml was named with the com_ prefix.