How to set Dynamic active_theme from my controller code
Nitinkumarwis opened this issue · 2 comments
I having four themes, I am creating an application where students can create pages using templates. I need to make it dynamic so if i select template one then i need to set template-one...
Here I set the template-one and template-two is set in my config pagebuilder.php. But When I run this code template-two theme opened.
How I can run this code with route action with dynamic active_theme?
Config::set('pagebuilder.theme.active_theme', 'template-one');
$route = $_GET['route'] ?? null;
$action = $_GET['action'] ?? null;
if( $request->page ){
$page_builder = BuilderPage::find( $request->page );
if( $page_builder ){
global $phpb_config;
$phpb_config['pagebuilder']['actions']['back'] = route('admin.list.pages',['page_id' => $page_builder->id]);
}
}
$pageBuilder = phpb_instance('pagebuilder');
phpb_set_in_editmode();
$pageBuilder->handleRequest($route, $action);
die("Page not found");
One way I found to solve this with the current version is adding more folders on your layouts folder of the theme. This way you can create multiple styles. The thing is is that the blocks will remain the same across all layouts.
For the time beign it doesnt seem this package supports multi theme selections to change blocks.
I tinkered a bit with the main package 'phpagebuilder' and you can change the set theme on the Theme.php file inside src folder.
In thepublic function _construct
add the next line
config()->set('pagebuilder.theme.active_theme', 'demo');
Change 'demo' for the name of your template that needs to exist on the themes folder and it will change the config on each load. Take in to account that you will have to extend the logic to change it depending on the user.