luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
812 stars 207 forks source link

Themes loader #1913

Closed zixxus closed 5 years ago

zixxus commented 5 years ago

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 * FROMadmin_configWHEREname= 'active_theme' limit 1;

QA

Q A
Is bugfix? no
New feature? yes
Breaks BC? no
Tests pass? no
boehsermoe commented 5 years ago

Nice feature! I had thought of something like that too. At first please revert your filemode changes like .gitignore 100644 → 100755 for more info see here After that it is easier too review. Thank you!

zixxus commented 5 years ago

Nice feature! I had thought of something like that too. At first please revert your filemode changes like .gitignore 100644 → 100755 for more info see here After that it is easier too review. Thank you!

Thanks :) I change file mode, but I don't know i should create new pull request?

nadar commented 5 years ago

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?

nadar commented 5 years ago

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.

zixxus commented 5 years ago

I review your comments and firstly I propose:

1) Rename all class and functions to Layouts (and similar to layouts) Class Layouts {

init() - for initialize all script getLayouts() - get all avaliable layouts (return all avaliable layouts, scan theme dir and load layout data from xml file) getLayout() - get one layout by name (with layout data like name, descr, author etc. loaded from getActive() - get current "on" layout (only name) getDir() - get Directory where layouts is stored.

}

2) Rewrite all arrays to objects.

2.1) Rewrite sql to Model.

2.2)

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.

I think it's a good idea, I will work on it.

3) Move code whose initialize layouts to CMS module and load it in controller (luya\cms\frontend\base\Controller).

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

4) Remove test class

5) Clear variables ( some variables can be place in component / controller).

98) Add theme uploader (.zip) and autoinstaller it.

99) Create docs for theme like what xml files should look like and etc.


yes themes loading is a good idea, what about the yii framework way of this? pro/cons?

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? :)

nadar commented 5 years ago

@zixxus @boehsermoe i made an issue, so we can discuss there and maybe close this PR:

https://github.com/luyadev/luya/issues/1916

zixxus commented 5 years ago

@zixxus @boehsermoe i made an issue, so we can discuss there any maybe close this PR:

1916

OK :)