Theme Resource Directory
Created 6 years ago by vinnydude

I have a feeling I'm overlooking something very very obvious here but it has me stumped. I've created a simple twig SVG plugin/function to output the raw data contained within. What I'm struggling with is getting the theme resource directory. I know it's really simple when you use the {{ image_url('theme::your file') }} but I can't seem to get the theme directory path when I'm creating my own twig function.

In short, how do I get the theme resource folder from within a plugin?!

ryanthompson  —  6 years ago

You can use the AddonCollection to pull out the active theme but once you have the theme use $addon->getPath('resources')

vinnydude  —  6 years ago

Thank you very much Ryan, that's given me a nice big nudge in the right direction!

ryanthompson  —  6 years ago

Forgot to mention you can get the active theme like this very much the same way:

$addons->themes->active($type); // Where type is "admin" or "standard"