Unable to set path and active theme
mirzap opened this issue · comments
Hi,
theme package works fine with options from the config file, where I have left default option for paths: paths.absolute => public_path('themes')
. And it works great, I have created default template in the public/themes
directory, added template files etc...
Now, for some part of my application, I need to use different theme directory. Let's say I have "system themes" and "user themes". I noticed you have two methods setPath($path)
and setActive($theme)
. Both are chainable and I should use it like this (in my controller):
private $theme;
public function __construct(\Caffeinated\Themes\Themes $theme)
{
parent::__construct();
$this->theme = $theme;
}
public function getRegister()
{
return $this->theme->setPath(public_path('clients'))->setActive('defaults')->view('users.account.register');
}
I've tried adding this part $this->theme->setPath(public_path('clients'))->setActive('defaults')
to the constructor, but I get the same error View [] not found.
The weird thing is if I dd getPath():
public function getRegister()
{
dd($this->theme->getPath());
return $this->theme->setPath(public_path('clients'))->setActive('defaults')->view('users.account.register');
}
I get the correct path "/home/vagrant/www/project/public/clients"
.
But, when I try this:
public function getPath()
{
dd($this->path);
return $this->path ?: $this->config->get('themes.paths.absolute');
}
I get null
. I'm struggling with this for couple days, and I would appreciate any help you can provide. Probably I don't see something so obvious :)
Hmm, this may be a legit bug - sounds like the main Themes
class isn't being initialized as a singleton like it's supposed to. I'll look into things and get back to you~