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) <noreply@anthropic.com>
This commit is contained in:
@@ -199,25 +199,35 @@ $faKitCode = trim((string) $this->params->get('fA6KitCode', ''));
|
|||||||
if ($faKitCode !== '') {
|
if ($faKitCode !== '') {
|
||||||
HTMLHelper::_('script', 'https://kit.fontawesome.com/' . $faKitCode . '.js', ['crossorigin' => 'anonymous']);
|
HTMLHelper::_('script', 'https://kit.fontawesome.com/' . $faKitCode . '.js', ['crossorigin' => 'anonymous']);
|
||||||
} else {
|
} else {
|
||||||
// Load local FA7 Free — all.css includes brands, solid, regular, fontawesome
|
// Load local FA7 Free — all.css via WebAsset
|
||||||
// Try media path first (proper Joomla install), then template path (SFTP deploy)
|
// Resolve the actual filesystem path: media dir (Joomla install) or template dir (SFTP deploy)
|
||||||
$faCss = $params_developmentmode ? 'vendor/fa7free/css/all.css' : 'vendor/fa7free/css/all.min.css';
|
$faCssFile = $params_developmentmode ? 'vendor/fa7free/css/all.css' : 'vendor/fa7free/css/all.min.css';
|
||||||
$faMediaPath = $templatePath . '/' . $faCss;
|
$faCandidates = [
|
||||||
$faLocalPath = 'templates/site/mokocassiopeia/media/' . $faCss;
|
$templatePath . '/' . $faCssFile, // media/templates/site/mokocassiopeia/...
|
||||||
|
'templates/site/' . $this->template . '/media/' . $faCssFile, // templates/site/mokocassiopeia/media/...
|
||||||
|
];
|
||||||
|
|
||||||
if (is_file(JPATH_ROOT . '/' . $faMediaPath)) {
|
// Also check via __DIR__ for edge cases
|
||||||
$wa->registerAndUseStyle('vendor.fa7free.all', $faMediaPath);
|
$faFromDir = __DIR__ . '/media/' . $faCssFile;
|
||||||
} elseif (is_file(JPATH_ROOT . '/' . $faLocalPath)) {
|
if (is_file($faFromDir)) {
|
||||||
$wa->registerAndUseStyle('vendor.fa7free.all', $faLocalPath);
|
$faCandidates[] = ltrim(str_replace('\\', '/', str_replace(JPATH_ROOT, '', $faFromDir)), '/');
|
||||||
} else {
|
}
|
||||||
// Last resort: try asset registry
|
|
||||||
$faAsset = $params_developmentmode ? 'vendor.fa7free.all' : 'vendor.fa7free.all.min';
|
$faRegistered = false;
|
||||||
try {
|
foreach ($faCandidates as $faPath) {
|
||||||
$wa->useStyle($faAsset);
|
if (is_file(JPATH_ROOT . '/' . $faPath)) {
|
||||||
} catch (\Throwable $e) {
|
$wa->registerStyle('vendor.fa7free.all', $faPath);
|
||||||
// Silent fail — FA icons will be missing
|
$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_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');
|
$params_rightIcon = htmlspecialchars($this->params->get('drawerRightIcon', 'fa-solid fa-chevron-right'), ENT_COMPAT, 'UTF-8');
|
||||||
|
|||||||
Reference in New Issue
Block a user