From 5af1a27676a41f6109b6528fa6902dd05a0bacae Mon Sep 17 00:00:00 2001 From: Jonathan Miller <230051081+jmiller-moko@users.noreply.github.com> Date: Sat, 4 Apr 2026 14:44:14 -0500 Subject: [PATCH] Fix FA7 not loading: simplify to single all.css, fix kit code check Simplify Font Awesome loading to scan three candidate paths for all.css, register whichever exists via WebAssetManager, then call useStyle(). Falls back to joomla.asset.json registry if no local file found. Covers both standard Joomla media path and SFTP deploy layout. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/index.php | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/index.php b/src/index.php index a85f013..3ebf99e 100644 --- a/src/index.php +++ b/src/index.php @@ -199,25 +199,35 @@ $faKitCode = trim((string) $this->params->get('fA6KitCode', '')); if ($faKitCode !== '') { HTMLHelper::_('script', 'https://kit.fontawesome.com/' . $faKitCode . '.js', ['crossorigin' => 'anonymous']); } else { - // Load local FA7 Free — all.css includes brands, solid, regular, fontawesome - // Try media path first (proper Joomla install), then template path (SFTP deploy) - $faCss = $params_developmentmode ? 'vendor/fa7free/css/all.css' : 'vendor/fa7free/css/all.min.css'; - $faMediaPath = $templatePath . '/' . $faCss; - $faLocalPath = 'templates/site/mokocassiopeia/media/' . $faCss; + // Load local FA7 Free — all.css via WebAsset + // Resolve the actual filesystem path: media dir (Joomla install) or template dir (SFTP deploy) + $faCssFile = $params_developmentmode ? 'vendor/fa7free/css/all.css' : 'vendor/fa7free/css/all.min.css'; + $faCandidates = [ + $templatePath . '/' . $faCssFile, // media/templates/site/mokocassiopeia/... + 'templates/site/' . $this->template . '/media/' . $faCssFile, // templates/site/mokocassiopeia/media/... + ]; - if (is_file(JPATH_ROOT . '/' . $faMediaPath)) { - $wa->registerAndUseStyle('vendor.fa7free.all', $faMediaPath); - } elseif (is_file(JPATH_ROOT . '/' . $faLocalPath)) { - $wa->registerAndUseStyle('vendor.fa7free.all', $faLocalPath); - } else { - // Last resort: try asset registry - $faAsset = $params_developmentmode ? 'vendor.fa7free.all' : 'vendor.fa7free.all.min'; - try { - $wa->useStyle($faAsset); - } catch (\Throwable $e) { - // Silent fail — FA icons will be missing + // Also check via __DIR__ for edge cases + $faFromDir = __DIR__ . '/media/' . $faCssFile; + if (is_file($faFromDir)) { + $faCandidates[] = ltrim(str_replace('\\', '/', str_replace(JPATH_ROOT, '', $faFromDir)), '/'); + } + + $faRegistered = false; + foreach ($faCandidates as $faPath) { + if (is_file(JPATH_ROOT . '/' . $faPath)) { + $wa->registerStyle('vendor.fa7free.all', $faPath); + $faRegistered = true; + break; } } + + // Use the asset — either our dynamic registration or the one from joomla.asset.json + try { + $wa->useStyle('vendor.fa7free.all'); + } catch (\Throwable $e) { + // All paths exhausted — FA icons will rely on the IcoMoon compat layer + } } $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');