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?

jakobfuchs
 
jakobfuchs replied on at Permalink Reply
jakobfuchs
Bump.
fudyartanto replied on at Permalink Reply
fudyartanto
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
jakobfuchs replied on at Permalink Reply
jakobfuchs
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.
jakobfuchs replied on at Permalink Reply
jakobfuchs
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.
pixolette replied on at Permalink Best Answer Reply
pixolette
Hi @jakobfuchs,

you have to use Config::set('app.theme_paths./login', 'your_theme_handle');
jakobfuchs replied on at Permalink Reply
jakobfuchs
Thanks! Going to try that immediately.
jakobfuchs replied on at Permalink Reply
jakobfuchs
Does not work for some reason :(
pixolette replied on at Permalink Reply
pixolette
File should be in theme, not in single_pages folder. Try to refresh multiple times, it's woking for me
jakobfuchs replied on at Permalink Reply
jakobfuchs
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.
pixolette replied on at Permalink Reply
pixolette
Try to do this in on_start function after setting /login page :

print_r(Cfg::get('app.theme_paths./login', 'eset_theme'));
die;


If everything is ok, it should print "eset_theme", else will be "concrete"
jakobfuchs replied on at Permalink Reply
jakobfuchs
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.
jakobfuchs replied on at Permalink Reply
jakobfuchs
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...
pixolette replied on at Permalink Reply
pixolette
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
surefyre replied on at Permalink Reply
surefyre
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.
jakobfuchs replied on at Permalink Reply
jakobfuchs
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:

\Route::setThemeByRoute('/login', 'my_theme_handle');