Core assets not loading when logged out using requireAsset
Permalink
The core assets that I am requiring in page_theme.php won't load when I am not logged in.
I copied and edited the Elemental theme to create a new custom theme in v8.1.0. I noticed that the assets aren't loading because my social media icons in the footer that use font-awesome aren't displaying. They load fine when I am logged in or if I am working in my local environment. However, the assets won't load on the production environment when I am logged OUT. If I activate the Elemental theme, the assets load just fine when I am logged in and out.
I have removed my theme and reinstalled it. I cleared all cache and disabled cache in C5. I cleared my local browser cache.
Here's the start of my page_theme.php.
I copied and edited the Elemental theme to create a new custom theme in v8.1.0. I noticed that the assets aren't loading because my social media icons in the footer that use font-awesome aren't displaying. They load fine when I am logged in or if I am working in my local environment. However, the assets won't load on the production environment when I am logged OUT. If I activate the Elemental theme, the assets load just fine when I am logged in and out.
I have removed my theme and reinstalled it. I cleared all cache and disabled cache in C5. I cleared my local browser cache.
Here's the start of my page_theme.php.
<?php namespace Application\Theme\CustomTheme; use Concrete\Core\Area\Layout\Preset\Provider\ThemeProviderInterface; use Concrete\Core\Page\Theme\Theme; class PageTheme extends Theme implements ThemeProviderInterface { public function registerAssets() { $this->requireAsset('css', 'font-awesome'); $this->requireAsset('javascript', 'jquery'); $this->requireAsset('javascript', 'picturefill'); $this->requireAsset('javascript-conditional', 'html5-shiv'); $this->requireAsset('javascript-conditional', 'respond'); }
Thank you MrKDilkington! I spent hours trying to figure this out. An underscore vs a hyphen is such a tedious detail and very easy to overlook.
To fix the issue, I changed the name of my theme directory on my server from "custom-theme" with a hyphen to "custom_theme" with an underscore. Then in the concrete5 admin dashboard under "Pages and Themes" I removed my theme and reinstalled it. Voila! Fixed. The required assets are now loading in the DOM no matter if I am logged in or out.
To fix the issue, I changed the name of my theme directory on my server from "custom-theme" with a hyphen to "custom_theme" with an underscore. Then in the concrete5 admin dashboard under "Pages and Themes" I removed my theme and reinstalled it. Voila! Fixed. The required assets are now loading in the DOM no matter if I am logged in or out.
Your theme handle should use an underscore to separate words and not a hyphen. Changing "mischief-studios" to "mischief_studios" should allow the page_theme.php to load.