This file is part of a Moko Consulting project. SPDX-License-Identifier: GPL-3.0-or-later This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/ . # FILE INFORMATION DEFGROUP: Joomla.Template.Site INGROUP: Moko-Cassiopeia PATH: ./templates/moko-cassiopeia/index.php VERSION: 03.00-RC BRIEF: Main template index file for Moko-Cassiopeia rendering site layout */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Uri\Uri; /** @var Joomla\CMS\Document\HtmlDocument $this */ $app = Factory::getApplication(); $input = $app->getInput(); $wa = $this->getWebAssetManager(); // Template params $params_ColorName = (string) $this->params->get('colorName', 'colors_standard'); // colors_standard|colors_alternative|colors_custom $params_googletagmanager = $this->params->get('googletagmanager', false); $params_googletagmanagerid = $this->params->get('googletagmanagerid', null); $params_googleanalytics = $this->params->get('googleanalytics', false); $params_googleanalyticsid = $this->params->get('googleanalyticsid', null); $params_custom_head_start = $this->params->get('custom_head_start', null); $params_custom_head_end = $this->params->get('custom_head_end', null); $params_leftIcon = htmlspecialchars($this->params->get('drawerLeftIcon', 'fa-solid fa-chevron-left'), ENT_COMPAT, 'UTF-8'); $params_rightIcon = htmlspecialchars($this->params->get('drawerRightIcon', 'fa-solid fa-chevron-right'), ENT_COMPAT, 'UTF-8'); // Bootstrap behaviors (assets handled via WAM) HTMLHelper::_('bootstrap.framework'); HTMLHelper::_('bootstrap.loadCss', true); HTMLHelper::_('bootstrap.alert'); HTMLHelper::_('bootstrap.button'); HTMLHelper::_('bootstrap.carousel'); HTMLHelper::_('bootstrap.collapse'); HTMLHelper::_('bootstrap.dropdown'); HTMLHelper::_('bootstrap.modal'); HTMLHelper::_('bootstrap.offcanvas'); HTMLHelper::_('bootstrap.popover'); HTMLHelper::_('bootstrap.scrollspy'); HTMLHelper::_('bootstrap.tab'); HTMLHelper::_('bootstrap.tooltip'); HTMLHelper::_('bootstrap.toast'); // Detecting Active Variables $option = $input->getCmd('option', ''); $view = $input->getCmd('view', ''); $layout = $input->getCmd('layout', ''); $task = $input->getCmd('task', ''); $itemid = $input->getCmd('Itemid', ''); $sitenameR = $app->get('sitename'); // raw for title composition $sitename = htmlspecialchars($sitenameR, ENT_QUOTES, 'UTF-8'); $menu = $app->getMenu()->getActive(); $pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : ''; // Respect “Site Name in Page Titles” (0:none, 1:before, 2:after) $mode = (int) $app->get('sitename_pagetitles', 0); $pageTitle = trim($this->getTitle()); $final = $pageTitle !== '' ? ($mode === 1 ? $sitenameR . ' - ' . $pageTitle : ($mode === 2 ? $pageTitle . ' - ' . $sitenameR : $pageTitle)) : $sitenameR; $this->setTitle($final); // Template/Media path $templatePath = 'media/templates/site/moko-cassiopeia'; // =========================== // Web Asset Manager (WAM) — matches your joomla.asset.json // =========================== // Core template CSS $wa->useStyle('template.base'); // css/template.css $wa->useStyle('template.user'); // css/user.css // Optional vendor CSS $wa->useStyle('vendor.bootstrap-toc'); // Color theme (light + optional dark) $colorKey = strtolower(preg_replace('/[^a-z0-9_.-]/i', '', $params_ColorName)); $lightKey = 'template.light.' . $colorKey; $darkKey = 'template.dark.' . $colorKey; try { $wa->useStyle($lightKey); } catch (\Throwable $e) { $wa->registerAndUseStyle('template.light.dynamic', $templatePath . '/css/global/colors/light/' . $params_ColorName . '.css'); } try { $wa->useStyle($darkKey); } catch (\Throwable $e) { // optional; omit if not present } // Scripts $wa->useScript('template.js'); $wa->useScript('theme-init.js'); $wa->useScript('darkmode-toggle.js'); $wa->useScript('vendor.bootstrap-toc.js'); // Font scheme (external or local) + CSS custom properties $params_FontScheme = $this->params->get('useFontScheme', false); $fontStyles = ''; if ($params_FontScheme) { if (stripos($params_FontScheme, 'https://') === 0) { $this->getPreloadManager()->preconnect('https://fonts.googleapis.com/', ['crossorigin' => 'anonymous']); $this->getPreloadManager()->preconnect('https://fonts.gstatic.com/', ['crossorigin' => 'anonymous']); $this->getPreloadManager()->preload($params_FontScheme, ['as' => 'style', 'crossorigin' => 'anonymous']); $wa->registerAndUseStyle('fontscheme.current', $params_FontScheme, [], [ 'media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'', 'crossorigin' => 'anonymous' ]); if (preg_match_all('/family=([^?:]*):/i', $params_FontScheme, $matches) > 0) { $fontStyles = '--font-family-body: "' . str_replace('+', ' ', $matches[1][0]) . '", sans-serif;' . "\n"; $fontStyles .= '--font-family-headings: "' . str_replace('+', ' ', isset($matches[1][1]) ? $matches[1][1] : $matches[1][0]) . '", sans-serif;' . "\n"; $fontStyles .= '--font-weight-normal: 400;' . "\n"; $fontStyles .= '--font-weight-headings: 700;'; } } else { $wa->registerAndUseStyle('fontscheme.current', $params_FontScheme, ['version' => 'auto'], [ 'media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'' ]); $this->getPreloadManager()->preload( $wa->getAsset('style', 'fontscheme.current')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style'] ); } } // Expose CSS variables (and any computed font variables) $wa->addInlineStyle(":root {\n --hue: 214;\n --template-bg-light: #f0f4fb;\n --template-text-dark: #495057;\n --template-text-light: #ffffff;\n --template-link-color: #2a69b8;\n --template-special-color: #001B4C;\n $fontStyles\n}"); // ------------------------------------- // Brand: logo from params OR siteTitle // ------------------------------------- $brandHtml = ''; $logoFile = (string) $this->params->get('logoFile'); if ($logoFile !== '') { $brandHtml = HTMLHelper::_( 'image', Uri::root(false) . htmlspecialchars($logoFile, ENT_QUOTES, 'UTF-8'), $sitename, ['class' => 'logo d-inline-block', 'loading' => 'eager', 'decoding' => 'async'], false, 0 ); } elseif ($this->params->get('siteTitle')) { $brandHtml = '' . htmlspecialchars($this->params->get('siteTitle'), ENT_COMPAT, 'UTF-8') . ''; } else { // Fallback to a bundled image (relative to media paths) $brandHtml = HTMLHelper::_('image', 'full_logo.png', $sitename, ['class' => 'logo d-inline-block', 'loading' => 'eager', 'decoding' => 'async'], true, 0); } // Layout flags $hasClass = ''; if ($this->countModules('sidebar-left', true)) { $hasClass .= ' has-sidebar-left'; } if ($this->countModules('sidebar-right', true)) { $hasClass .= ' has-sidebar-right'; } if ($this->countModules('drawer-left', true)) { $hasClass .= ' has-drawer-left'; } if ($this->countModules('drawer-right', true)) { $hasClass .= ' has-drawer-right'; } // Container $wrapper = $this->params->get('fluidContainer') ? 'wrapper-fluid' : 'wrapper-static'; $stickyHeader = $this->params->get('stickyHeader') ? 'position-sticky sticky-top' : ''; // Meta $this->setMetaData('viewport', 'width=device-width, initial-scale=1'); // Optional Font Awesome Kit (not defined in JSON) if ($this->params->get('fA6KitCode')) { $fa6Kit = "https://kit.fontawesome.com/" . $this->params->get('fA6KitCode') . ".js"; HTMLHelper::_('script', $fa6Kit, ['crossorigin' => 'anonymous']); } ?>