-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic loading of themes / Enable & add themes with PHP #110
Comments
The solution is:
Maybe this should be added to the documentation. I think it would be good if anybody could add this function to ActiveTheme class:
or:
|
Why do you want do that? To me theme list should be defined permanently in configs, otherwise it's something that you don't control. |
We are using a dynamic system to upload, enable and disable themes. All settings should be saved in the database. Is there any way to disable the "it must be in the array (theme-list)"-feature? It would be great if the system would just try to find the theme based on the name (directory name = theme name). |
I do agree that dynamic loading of themes is a legitimate use case. |
@JHGitty now it makes sense, I'm also +1 for idea. |
Assetic problems in combination with dynamically add/enable themes.
I tried to dynamically add and set the theme with an event listener for kernel.controller
If I add and enable the theme in config.yml this problem seems to be fixed. But I need to dynamically add and enable themes. This problem appears because I use an eventlistener which will be called after TemplateResourcesPass (https://github.com/liip/LiipThemeBundle/blob/master/DependencyInjection/Compiler/TemplateResourcesPass.php) Same problem as Issue #25. How should I set the theme with PHP to avoid this problem? |
long time since I worked on that part of the code. we "inject" the theme directories into assetic here from my reading: now I am not sure if the assetic API allows for dynamically adding more directories but I doubt that this would be at all useful, since assetic's CLI dump command would then never know about those directories. meaning you would also have to do something to the dump process. in the end, I would say its easier to just keep assetic resource introduction out of theme templates. |
ping |
I am not working on this. I just created the issue. I hope anybody else will do it. |
public function prepend(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
if (isset($bundles['LiipThemeBundle'])) {
$themes = [];
$finder = new Finder();
foreach($finder->path('/\/Resources\/themes\/.*$/')->directories()->in($container->getParameter('kernel.root_dir').'/..') as $directory)
{
if(strstr($directory->getPath(), "Tests") === false)
{
if(!in_array($directory->getFilename(), $themes))
$themes[] = $directory->getFilename();
}
}
$config = [
"assetic_integration" => true,
"themes" => $themes,
"active_theme" => 'default',
'path_patterns' => [
'app_resource' => [
__DIR__.'/../Resources/themes/default/%%template%%'
]
]
];
$container->prependExtensionConfig("liip_theme", $config);
}
} Actually i made the bundle dynamically search for the themes. removal of the marked bracket will detect the foobar theme from tests. |
feel free to submit this as a PR .. I guess it would be configured as a single or multiple glob statements? |
sorry i just realised that i missed a chunk of code. eg: ["theme1","theme2", "theme3"] after which it will set the configuration of liip_theme:themes as the array after which the system will kick in and do the rest as follows given that that this will dynamically fetch all the theme name and build the array there are a couple of options. which one would you like to see implemented? |
How may I add a theme to the theme-list with PHP?
I like to dynamically add the theme by an event listener.
I can set the active theme by PHP:
=> The active theme "blue" must be in the themes list ().
How to add any theme name to the "theme list" ?
The text was updated successfully, but these errors were encountered: