How to set theme_paths from Package Controller
Permalink
I want to use custom pages for login, register etc. The way to normally do it is to create a "theme_paths" array in the application/config/app.php. I was wondering if it is possible to set this array in my package controller and how this could be achieved.
With the Config::set() method i can do stuff like Config::set('concrete.debug.detail', 'debug'); but it seems it is not possible to do something like this:
Config::set('app.theme_paths.login', 'theme_name');
Am I doing something wrong here, or is it just not possible?
With the Config::set() method i can do stuff like Config::set('concrete.debug.detail', 'debug'); but it seems it is not possible to do something like this:
Config::set('app.theme_paths.login', 'theme_name');
Am I doing something wrong here, or is it just not possible?
Bump.
Concrete version.?
Can you describe what you want to do..?
To set theme path I think you need setup View object.
Just try to give you hint (concrete5.7).
Try to take a look View Object in \concrete\src\View\View.php
check method loadViewThemeObject(), and setViewTheme()
good luck
Can you describe what you want to do..?
To set theme path I think you need setup View object.
Just try to give you hint (concrete5.7).
Try to take a look View Object in \concrete\src\View\View.php
check method loadViewThemeObject(), and setViewTheme()
good luck
Thanks for your answer.
I am using 5.7.3.1.
Like I said in the original post, I want to set the theme_paths array in /config/app.php automatically from my theme's package controller. Using Config::set() I can change the arrays in /config/concrete.php but not in /config/app.php.
As i see it the Config::set() method saves the config overrides in the ConfigStore Database Table. But when I actually look there, the changed settings are not reflected there. But they apply anyway. They also can't be found in application/config/concrete.php or concrete/config/concrete.php.
I took a look at the class you suggested and I think this class makes use of the settings defined by the theme_paths array, but I saw no way to set it there.
I am using 5.7.3.1.
Like I said in the original post, I want to set the theme_paths array in /config/app.php automatically from my theme's package controller. Using Config::set() I can change the arrays in /config/concrete.php but not in /config/app.php.
As i see it the Config::set() method saves the config overrides in the ConfigStore Database Table. But when I actually look there, the changed settings are not reflected there. But they apply anyway. They also can't be found in application/config/concrete.php or concrete/config/concrete.php.
I took a look at the class you suggested and I think this class makes use of the settings defined by the theme_paths array, but I saw no way to set it there.
Bump. Still couldn't figure this out. To reiterate: I want to set the theme_paths array on package installation, so that the user doesn't have to do this manually.
Hi @jakobfuchs,
you have to use Config::set('app.theme_paths./login', 'your_theme_handle');
you have to use Config::set('app.theme_paths./login', 'your_theme_handle');
Thanks! Going to try that immediately.
Does not work for some reason :(
File should be in theme, not in single_pages folder. Try to refresh multiple times, it's woking for me
I tried refreshing.
Here's the relevant part of my package controller in case you spot an error there:
public function on_start() {
// Dev Settings
Cfg::set('concrete.accessibility.display_help_system', false);
Cfg::set('concrete.debug.detail', 'debug');
Cfg::set('concrete.cache.enabled', false);
Cfg::set('concrete.cache.overrides', false);
Cfg::set('concrete.cache.blocks', false);
Cfg::set('concrete.cache.assets', false);
Cfg::set('concrete.cache.theme_css', false);
// Custom Single Pages
Cfg::set('app.theme_paths./login', 'eset_theme');
Cfg::set('app.theme_paths./maintenance_mode', 'eset_theme');
}
Edit: login.php and maintenance_mode.php are in the root of my theme folder
Edit 2: if I inspect my theme the template shows up with the following message: This file will automatically be used by the Login page.
Here's the relevant part of my package controller in case you spot an error there:
public function on_start() {
// Dev Settings
Cfg::set('concrete.accessibility.display_help_system', false);
Cfg::set('concrete.debug.detail', 'debug');
Cfg::set('concrete.cache.enabled', false);
Cfg::set('concrete.cache.overrides', false);
Cfg::set('concrete.cache.blocks', false);
Cfg::set('concrete.cache.assets', false);
Cfg::set('concrete.cache.theme_css', false);
// Custom Single Pages
Cfg::set('app.theme_paths./login', 'eset_theme');
Cfg::set('app.theme_paths./maintenance_mode', 'eset_theme');
}
Edit: login.php and maintenance_mode.php are in the root of my theme folder
Edit 2: if I inspect my theme the template shows up with the following message: This file will automatically be used by the Login page.
Thanks for helping to debug this.
It does print out my theme name, but the login page is still the default concrete5 single page. I have no idea why.
I changed the statement to:
print_r(Cfg::get('app.theme_paths./register', 'eset_theme'));
and it prints out "concrete" which is correct, since I didn't change the register.php page.
It does print out my theme name, but the login page is still the default concrete5 single page. I have no idea why.
I changed the statement to:
print_r(Cfg::get('app.theme_paths./register', 'eset_theme'));
and it prints out "concrete" which is correct, since I didn't change the register.php page.
I really have no idea why it doesn't work but I marked your answer as the best anyways.
Server restart, clearing cache etc. does not work. Maybe it gets overwritten elsewhere...
Server restart, clearing cache etc. does not work. Maybe it gets overwritten elsewhere...
Hi,
You can debug it in another way:
Create register page and rewrite it, to check if problem is just in login page or in all system pages
You can debug it in another way:
Create register page and rewrite it, to check if problem is just in login page or in all system pages
Hi jakobfuchs - 'set' doesn't seem to work but 'save' does:
\Config::save('app.theme_paths./login', ['theme_name']);
Idiotically though, 'clear' uses 'set' to clear a value so you have to delete the app file manually to revert as you can't unwrite the file on uninstall in your package. Bit stupid, that.
Going to ask why set doesn't do what you'd think as putting it in the on_start seems the totally obvious thing to do for changing login pages, etc. Why the good old single page override doesn't just work like it used to is another mystery for another day though.
\Config::save('app.theme_paths./login', ['theme_name']);
Idiotically though, 'clear' uses 'set' to clear a value so you have to delete the app file manually to revert as you can't unwrite the file on uninstall in your package. Bit stupid, that.
Going to ask why set doesn't do what you'd think as putting it in the on_start seems the totally obvious thing to do for changing login pages, etc. Why the good old single page override doesn't just work like it used to is another mystery for another day though.
Yeah, I think set just overrides the value 'dynamically' for every request, but the values for these particular items can't be changed after the config file has been processed (for whatever reason).
The best solution I have found since posting this question two and a half years ago is this:
The best solution I have found since posting this question two and a half years ago is this:
\Route::setThemeByRoute('/login', 'my_theme_handle');