I try to make a component who use layout from theme.
$this->theme = Theme::getActiveTheme(); $this->assetPath = $this->themeUrl(); // return 'themes/demo' $partialPath = $this->getViewPath($partial, $this->assetPath .'/layouts/section');
and I have a exception The partial '/themes/demo/layouts/section/_test.htm' is not found.
How can I get root path of theme ?
The partial '[path]/themes/demo/layouts/section/_test.htm' is not found. [path] is undefined or I need to use classe ?
The [path] was just a holder, ignore it, was just incase you need to go up a few directories like
If the above is placed in the
acme/plugin/components/Component.php file, this path will work
"themes/".Config::get("cms.activeTheme",'')."/layouts/_test.htm". Just remember to
Works perfectly. Thanks !
Might want to use PHP constant DIRECTORY_SEPARATOR instead of "/" for M$ server compatability.
define('DS',DIRECTORY_SEPARATOR); $this->page['test'] = "themes".DS.Config::get("cms.activeTheme",'').DS."layouts".DS."_test.htm";
I run across this old post, after searching for a similar problem. The answers here, aren't entirely right.
Will return the active theme on config/cms.php. Witch my not be the active theme (eg.: if the active theme is set on the backend ).
To get the "real" active theme, should be something like this.
$theme = Theme::getActiveTheme(); $path = Config::get('cms.themesPath', '/themes').'/'.$theme->getDirName();
more info in:
I was trying to do something similar but since the suggested solution looks at the config this doesn't quite work the frontend theme is changed on the backend.
I think @davidmassianirennes347 was in the right track ...
Here's how I've done to make sure we are getting the current active theme path:
use Cms\Classes\Theme; $theme = Theme::getActiveTheme(); $theme_path = $theme->getPath();
Hope this is useful for someone in the future.
1-8 of 8