From a767f9799591c8041a4e140fee661ee245eaeb37 Mon Sep 17 00:00:00 2001 From: Jonathan Miller <230051081+jmiller-moko@users.noreply.github.com> Date: Sat, 4 Apr 2026 14:18:18 -0500 Subject: [PATCH] Fix FA7 not loading: try both media and template paths Font Awesome CSS was not loading because the asset path (media/templates/site/mokocassiopeia/) doesn't exist when deployed via SFTP to the template directory. Now checks the file system for both the standard Joomla media path and the SFTP-deployed template-relative path before falling back to the asset registry. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/index.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/index.php b/src/index.php index d6a208b..a7d682a 100644 --- a/src/index.php +++ b/src/index.php @@ -200,13 +200,23 @@ if ($faKitCode !== '') { HTMLHelper::_('script', 'https://kit.fontawesome.com/' . $faKitCode . '.js', ['crossorigin' => 'anonymous']); } else { // Load local FA7 Free — all.css includes brands, solid, regular, fontawesome - $faAsset = $params_developmentmode ? 'vendor.fa7free.all' : 'vendor.fa7free.all.min'; - try { - $wa->useStyle($faAsset); - } catch (\Throwable $e) { - // Fallback: register dynamically if asset not in registry - $faCss = $params_developmentmode ? 'vendor/fa7free/css/all.css' : 'vendor/fa7free/css/all.min.css'; - $wa->registerAndUseStyle('vendor.fa7free.all.dynamic', $templatePath . '/' . $faCss); + // 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; + + 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 + } } } $params_leftIcon = htmlspecialchars($this->params->get('drawerLeftIcon', 'fa-solid fa-chevron-left'), ENT_COMPAT, 'UTF-8');