-
Notifications
You must be signed in to change notification settings - Fork 206
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 loader #1913
Themes loader #1913
Conversation
Nice feature! I had thought of something like that too. At first please revert your filemode changes like |
Thanks :) I change file mode, but I don't know i should create new pull request? |
I will do a review tomorrow, this looks promising for me! i have some Inputs regarding naming, and i think we need an object for the theme itself, isntead of an array with keys. is there a preview of the themes management module somewhere? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zixxus i did a short review now. I think we can not merge this PR, because:
- luya core must work without database, its just the MVC extended basic application.
- the theme should be stored in an object not an array with keys
I made some comments on the given situations, see above.
Summary:
- yes themes loading is a good idea, what about the yii framework way of this? pro/cons? https://www.yiiframework.com/doc/guide/2.0/en/output-theming
- yes, maybe the themes component should be the main place for communication inside the application, but logic which theme is loaded etc. should be done in the CMS module via bootstraping.
@@ -246,6 +246,10 @@ public function applicationConsole() | |||
], | |||
]); | |||
$this->app = new ConsoleApplication($mergedConfig); | |||
|
|||
$this->theme = Yii::$app->themes->getTheme(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setting alias should be done in the bootstrap section /base/BaseBootstrap
/** | ||
* @var string The default file of layout | ||
*/ | ||
public $layout = 'main'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layouts must be defined in the controller, i don't think we can introduce this variable here.
/** | ||
* @var string The default folder of theme load | ||
*/ | ||
public $theme; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The theme should be configured via the component, so i think the path for the layout should be extract from the themes component.
* @return string | ||
* @see \yii\base\Module::getLayoutPath() | ||
*/ | ||
public function getLayoutPath() | ||
{ | ||
$this->theme = Yii::$app->themes->getTheme(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The layout file must be set in the controller, as mentioned above. Also not sure about error handling, cause there should be the question:
- what kind of errors can a theme have?
@@ -0,0 +1,188 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, yes i agree we could added a themes component to luya which will be the main channel to communicate whether a theme exists or not, and which one is active. etc. So maybe we could keep this component, but improve it and make it the main channel to communicate between controller, views and application.
public function setup() | ||
{ | ||
|
||
$this->config['active'] = $this->getActive(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of an array we need an object.
*/ | ||
public function getActive() | ||
{ | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work for other DBMS system therefore we would need active query, but its not allowed to make database requests in LUYA core as its mvc only and no database is needed. So the CMS must inject this information to the themes component in a bootstrap section for example.
@@ -0,0 +1,52 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how usefull those tests are 😄
In addition i also would like to say that we maybe need an issue where we can discuss the GOALS of the themes option and how we can get there. What are specifications of a theme? how are they stored (xml? database?) how to install and load, etc. |
I review your comments and firstly I propose:
init() - for initialize all script }
2.1) Rewrite sql to Model. 2.2)
I think it's a good idea, I will work on it.
In core i'll leave only Layouts component and also load this component. In the administrator module I leave only Layouts managment wherein we can switch themes. Maybe I add function to create / load child themes but at a later time :) Are you think I can split theme managment for two modules or it will be better when all code put into luya-module-cms/src/admin? In this I thinking about page in whose we can managment themes. This page will be placed for example in: https://demo.luya.io/en/admin#!/template/admin~2Flayouts~2Findex
Often I write themes and modules for wordpress, my clients like when page is simple, If he need to change theme or theme variables its be required in admin panel not in code. Also some clients buy themes and scipts and it need installer like "Theme install" button. I think it be more usefull than YII array with theme managment and more programmers will start using luya because it will be more readable. What are you think about this? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also some clients buy themes and scipts and it need installer like "Theme install" button.
Of course it is easier for a client but at first it should be easy for the developers to install and configure a theme. This could be a later feature when there is something like a "marketplace" for luya themes.
And also need a api for themes.
What is with extending or overriding exists themes? This does not have to be implemented at the beginning but should be take into consideration.
As @nadar says in general we need a issue to collect and discuss features/goals/ideas.
|
||
|
||
if (file_exists($path . '/theme.xml')) { | ||
$xml = simplexml_load_string(file_get_contents($path . '/theme.xml')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theme infos should be stored in a json because theme config has no complex structure. Maybe it could also stored in the composer.json in the "extra" section?
@zixxus @boehsermoe i made an issue, so we can discuss there and maybe close this PR: |
OK :) |
What are you changing/introducing
At first, this require:
https://github.com/zixxus/luya/tree/theme
https://github.com/zixxus/luya-env-dev/tree/themes
https://github.com/zixxus/luya-module-cms/tree/themes
Add Theme component
Add global variable @theme
Add folder /themes with XML file where we configure the template
Remove resources & views folder - now its be replaced
What is the reason for changing/introducing
I decided that many people prefer to manage their templates in the same way as it is in wordpress or prestashop. In the coming days, the template management module will appear in the admin panel.
In the future, he also proposes to add child themes, which will help the developer sell one template to many clients.
Currently the default theme is / themes / blank. We can change them through the sql code:
SELECT * FROM
admin_configWHERE
name= 'active_theme' limit 1;
QA