Loading Icons from OctoberCMS into a Form Widget

Hey everyone. Is there a way to load the internal icon library as a form widget, preferably a relation, in October CMS?

1 Like

I had a similar issue and in the end I just created a simple function to parse all icons from the CSS file:

public function parseIconsFromCss($path, $prefix)
{
    $basePath= base_path('modules/backend/assets/foundation/elements');
    $file = file_get_contents($basePath . $path);
    preg_match_all('/' . preg_quote($prefix) . '[a-z0-9-]+/', $file, $matches);

    return array_unique($matches[0])
}

So to get all octo icons you can call:

$this->parseIconsFromCss('/octoicons/octoicons.less', 'octo-icon-');

And to get all fontAwesome icons you can call:

$this->parseIconsFromCss('/icons/icons.all.less', 'oc-icon-');

This code works for the lastest 3.x release and may need to be adjusted for earlier releases.

1 Like

That is awesome! I haven’t tried it yet, but I’ll take your word for it!