Skip to content

Kirby 6.0.0

CSS URLs

Used by the css() helper

/site/plugins/css-helper/index.php
Kirby::plugin(
   name: 'my/css',
   extends: [
      'components' => [
         'css' => function (App $kirby, string $url, $options = null): string {
             $relative_url = Url::path($url, false);
             $file_root = $kirby->root('index') . DS . $relative_url;

             if (F::exists($file_root)) {
                 return url($relative_url . '?' . F::modified($file_root));
             }

             return $url;
         }
     ]
   ]
);

Parameters

Name Type Default Description
$kirbyrequired Kirby\Cms\App no default value
$urlrequired string no default value Relative or absolute URL
$options stringorarray null An array of attributes for the link tag or a media attribute string

Return type

string