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) <noreply@anthropic.com>
This commit is contained in:
@@ -200,13 +200,23 @@ 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 includes brands, solid, regular, fontawesome
|
||||||
$faAsset = $params_developmentmode ? 'vendor.fa7free.all' : 'vendor.fa7free.all.min';
|
// Try media path first (proper Joomla install), then template path (SFTP deploy)
|
||||||
try {
|
$faCss = $params_developmentmode ? 'vendor/fa7free/css/all.css' : 'vendor/fa7free/css/all.min.css';
|
||||||
$wa->useStyle($faAsset);
|
$faMediaPath = $templatePath . '/' . $faCss;
|
||||||
} catch (\Throwable $e) {
|
$faLocalPath = 'templates/site/mokocassiopeia/media/' . $faCss;
|
||||||
// Fallback: register dynamically if asset not in registry
|
|
||||||
$faCss = $params_developmentmode ? 'vendor/fa7free/css/all.css' : 'vendor/fa7free/css/all.min.css';
|
if (is_file(JPATH_ROOT . '/' . $faMediaPath)) {
|
||||||
$wa->registerAndUseStyle('vendor.fa7free.all.dynamic', $templatePath . '/' . $faCss);
|
$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');
|
$params_leftIcon = htmlspecialchars($this->params->get('drawerLeftIcon', 'fa-solid fa-chevron-left'), ENT_COMPAT, 'UTF-8');
|
||||||
|
|||||||
Reference in New Issue
Block a user