Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Assets PHP addCSS() with theme:// not working as expected

Solved by Daniel Idzerda View solution

Started by Daniel Idzerda 8 years ago · 1 replies · 775 views
8 years ago

The theme that I am currently trying to extend (Clean-Blog) doesn't have the custom.css in its template files like antimatter has. So to avoid having to override the whole base.html.twig I thought I could add it in the theme PHP file through the assets interface. The code that I am using is as follows:

PHP
namespace Grav\Theme;

use Grav\Common\Theme;

class CleanBlogChild extends Theme {

    public static function getSubscribedEvents()
        {
          return [
              'onThemeInitialized' => ['onThemeInitialized', 0]
          ];
        }

    public function onThemeInitialized() {
        $this->grav['assets']->addCss('theme://css/custom.css', 5);
    }
}

if i understand this correctly it should output a link with the url as follows /user/themes/clean-blog-child/css/custom.css instead it is outputting user/themes/clean-blog-child/css/custom.css so when it is inserting on a page not at the root of the site it fails to load. For example a blog post.

This is my first foray into Grav so I might just be missing something.
Thanks,

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 197 2 months ago
Themes & Styling · by Ian, 2 months ago
3 93 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 454 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 47 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 127 3 months ago