diff --git a/src/opnsense/mvc/app/config/services.php b/src/opnsense/mvc/app/config/services.php index 464a5db95..4f11315d4 100644 --- a/src/opnsense/mvc/app/config/services.php +++ b/src/opnsense/mvc/app/config/services.php @@ -41,6 +41,12 @@ $di->set('view', function () use ($config) { 'compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_' )); + // register additional volt template functions + $volt->getCompiler()->addFunction('javascript_include_when_exists', function($local_url) { + $chk_path = "str_replace('/ui/','/usr/local/opnsense/www/',".$local_url.")"; + $js_tag = "''"; + return "file_exists(".$chk_path.") ? ".$js_tag." :''"; + }); return $volt; }, diff --git a/src/opnsense/mvc/app/views/layouts/default.volt b/src/opnsense/mvc/app/views/layouts/default.volt index 2bbcd5880..e10d7113f 100644 --- a/src/opnsense/mvc/app/views/layouts/default.volt +++ b/src/opnsense/mvc/app/views/layouts/default.volt @@ -14,9 +14,10 @@ {{title|default("OPNsense") }} + {% set theme_name = ui_theme|default('opnsense') %} - + - + - + - + @@ -179,6 +180,7 @@ + {{javascript_include_when_exists('/ui/themes/' ~ theme_name ~ '/build/js/theme.js')}} @@ -187,8 +189,8 @@