Skip to content
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

Themes Loading #1916

Closed
nadar opened this issue Apr 9, 2019 · 9 comments · Fixed by #1936
Closed

Themes Loading #1916

nadar opened this issue Apr 9, 2019 · 9 comments · Fixed by #1936

Comments

@nadar
Copy link
Member

nadar commented Apr 9, 2019

Goal

Developers (and maybe in future also Clients/Admin-Users) should be able to install a new LUYA theme for the Frontend.

Where is the data stored?

Where is the theme data stored and transfered? Zip? Vendor? public_html folder? new /theme folder?

How does the mechanism work

  1. (core) The module $layoutPath (https://www.yiiframework.com/doc/api/2.0/yii-base-module#$layoutPath-detail) can be changed by a theme in order to point to the theme file.
  2. The cms bootstrap section can check for a theme and therefore change the module $layouPath (1.) (actually this can be skiped at first version, because any module can provide a bootstrap section - so maybe the new theming module can do this byitself therefore we don't have to touch the cms)
  3. An application component holds the information about what theme is currently loaded with its specific functions and properties (Yii::$app->theming ?)

How to setup a theme?

It should be possible to configure the theme via config, like:

'theming' => [
   'activeTheme' => ['.....path/to/theme.json?', '/path/to/Theme.php?']
]

So this step can later be done by module bootstrap section.

Questions

  • What does a theme contain?
  • where is theme data stored?
@zixxus
Copy link

zixxus commented Apr 9, 2019

Where is the theme data stored and transfered? Zip? Vendor? public_html folder? new /theme folder?

I propose to default store data in /themes as separate folder for every theme

@zixxus
Copy link

zixxus commented Apr 9, 2019

3\. An application component holds the information about what theme is currently loaded with its specific functions and properties (Yii::$app->theming ?)

Yes I think Yii::$app->theming or Yii::$app->layouts (Depending on what naming we accept). In this variable we can store active theme data as object like name, author, path, version, author url.

@zixxus
Copy link

zixxus commented Apr 9, 2019

* What does a theme contain?

* where is theme data stored?

At first i propose to make theme like default YII. Views and other data should work on the principle of overwriting default file structure.

I think the template data should be stored as JSON in the main catalog of theme like /themes/blank/theme.json

@nadar
Copy link
Member Author

nadar commented Apr 9, 2019

Theme Folders contain:

  • A layout file
  • An asset file - this means we need PHP files, this means we need to have a namespace...
  • css and js code which is registered in the asset.

How are themes installed?

Is it a zip which is extracted into the themes folder (problem with namespaces!)? Or maybe installed via composer?

@zixxus
Copy link

zixxus commented Apr 9, 2019

In fact, it can cause us a small problem. We can try to define namespace directly from the component and then do the installer as a zip. Alternatively, we can do so that the theme was built using a composer, but as a separate package and not inside luya/vendor

@boehsermoe
Copy link
Member

How are themes installed?

I would prefer to install theme via composer (it should be enough for the first) . So we could also define the theme path as extra config in the composer.json like the block path and this will be saved in the installer.php and will be update via ./luya import.

I doing some refactoring and will make ne PR. Maybe we should also open a new branch for this feature. What do think @nadar ?

@nadar
Copy link
Member Author

nadar commented Jul 14, 2019

In general this sounds good to me, but i have some questions:

  1. how is the theme activated then? Because what happens if you install two theme extensions?
  2. What does the theme itself look like? Because i think this is what matters, or are we just using yii2 theme options? https://www.yiiframework.com/doc/guide/2.0/en/output-theming

@boehsermoe
Copy link
Member

boehsermoe commented Jul 15, 2019

Active Theme

Default theme path will be @app/themes/blank and the active theme should be defined via config

'themeManager' => [
   'activeTheme' => '@app/theme/qwertz', // maybe the theme path or a unique name (combine of vendor package and theme name)?
]

Theme manager

This component will load the active luya theme into the yii view theme component. Because this should be changeable in runtime. So the theme manager will only handle the luya specified theme config and configure the yii theme with the correct paths to handle all the view loading.

 'components' => [
        'view' => [
            'theme' => [
                'basePath' => {will set by theme manager},
                'baseUrl' => {will set by theme manager},
                'pathMap' => [
                    '@app/views' => {will set by theme manager},
                ],
            ],
        ],
    ],

@nadar
Copy link
Member Author

nadar commented Jul 23, 2019

So you have to activate them in your config, but the themes information is somewhere assigned to an array with config from composer 👍

Yes lets create a branch with a draft PR pointing to this issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants