Announcement

  •  » Engine
  •  » New architecture for themes

#1 2010-03-11 22:45:27

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

New architecture for themes

Hi Piwigo coders!

While wondering how to build the theme manager in [Forum, topic 14925] [evolution] Management of the template/theme, the discussions partly derived to the internal architecture of templates + themes. Shouldn't we put themes outside the template? shouldn't we distribute a template with no theme + a theme depending on the template? and so on.

Then saimon came.

I read with attention what he wrote in [Forum, post 112026 by saimon in topic 14925] [evolution] Management of the template/theme. In this post, saimon describes the theme architecture in Dotclear.

Then I said "Woaw". This is simpler than what we do and you can do more.

1) simpler: forget about template. They have themes, only 1 level. Their *.tpl files are in themes/default/tpl/*.tpl

2) do more: inheritance. All themes derives from themes/default. A theme may also have an explicit parent.

Example: you like theme/dark, but you would like it slightly darker. You create theme/darker and declare dark as its parent theme. In darker you only have 2 files : themeconf.inc.php + theme.css (with 3 CSS rules only, only what you want to overwrite)

Then I discussed with P@t to ask his opinion about the way Dotclear was working for themes. He was really impressed and started to write a proof of concept (POC). It was 22 hours ago.

Today P@t sent me the POC.zip. Have a look : http://piwigo.us/work_in_progress/notemplate

P@t moved many files for a new organization. template-common was emptied and deleted.

"theme" directory is at the root of Piwigo. The result is something like:

Code:

theme
|-- Sylvia
|   |-- icon
|   |   `-- mimetypes
|   `-- images
|-- clear
|-- dark
|   `-- images
|-- default
|   |-- icon
|   |   |-- admin
|   |   `-- mimetypes
|   |-- js
|   |   |-- plugins
|   |   `-- ui
|   |       |-- i18n
|   |       |-- minified
|   |       |-- packed
|   |       `-- theme
|   |-- mail
|   |   `-- text
|   |       |-- html
|   |       |   `-- images
|   |       `-- plain
|   `-- template
|       `-- include
|-- p0w0
|   `-- images
`-- wipi
    `-- images

The work is not finished, but it is "working" as is. Changing the theme is working fine.

Why I find this new architecture very interesting: because it's simpler. No question about how to manage templates on piwigo.org/ext or in the future theme manager inside Piwigo administration. In addition to this, I think that simplicity will generate more various themes in the end.

Today we can compare the external contributions for themes versus plugins. I believe that the first thing a user will customize is the theme. BUT in the extension manager, we have 50 themes versus 115 plugins. Plugins is PHP code and we could suppose it's harder to write. I think that plugin architecture is better than theme architecture and it partly explains why we don't have many contributed themes.

What's your opinion?

Offline

 

#2 2010-03-11 23:20:57

flop25
Piwigo Team
2006-07-06
7037

Re: New architecture for themes

hello
just to say at my first lecture my state of mind : it's a revolution ! I feel seduce by changing the way of using template and theme because of the over-complexicity of the current structure, but also a little scared of the management of the template. It's late and I have not thought about it deeply.
It will be easier for the theme manager ^^

Last edited by flop25 (2010-03-11 23:21:32)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2010-03-11 23:22:06

rub
Former Piwigo Team
Lille
2005-08-26
5019

Re: New architecture for themes

It's interesting!
After template including theme and now theme including template. In fact, now, the difference between theme and template are natural.
It's surely more easy to understand and to modify!


Questions:
  o inheritance for each kind of files? (tpl, js, img, ...)
  o inheritance with several level?
  o directory mail shoud not be on template directory (like include) / and mails/images in icon/mail or images/mail?
  o directory on default theme and other must be the same?

With gives:

Code:

theme
|-- Sylvia
|   |-- icon
|   |   `-- mimetypes
|   `-- images
|-- clear
|-- dark
|   `-- images
|-- default
|   |-- images
|   |   |-- icon
|   |   |   |-- admin
|   |   |   `-- mimetypes
|   |   |-- mails
|   |-- js
|   |   |-- plugins
|   |   `-- ui
|   |       |-- i18n
|   |       |-- minified
|   |       |-- packed
|   |       `-- theme
|   `-- template
|   |   `-- include
|   |-- mail
|   |   `-- text
|   |       |-- html
|   |       `-- plain
|-- p0w0
|   `-- images
`-- wipi
    `-- images

Last edited by rub (2010-03-11 23:25:23)

Offline

 

#4 2010-03-11 23:28:00

VDigital
Former Piwigo Team
Paris (FR)
2005-05-04
17680

Re: New architecture for themes

To clarify:

1 - Template-extension
2 - Local-layout
3 - Themeconf.inc.php changes
4 - CSS consequences

5 - Impacts on migration

I have no idea on each point currently.
What will happen to 2.1 delivery?
Does that mean it will be postponed for a medium size period of release candidate?

I need to understand all of these events.


Piwigo.com: Start and run your own photo gallery. Signup and get 30 days to try for free, no commitment.
8-)

Offline

 

#5 2010-03-11 23:45:48

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

rub wrote:

Questions:
  o inheritance for each kind of files? (tpl, js, img, ...)

tpl => yes (automatic)
js =>

Code:

./theme/default/template/header.tpl:<script type="text/javascript" src="{$ROOT_URL}{$themeconf.js_dir}/scripts.js"></script>

conclusion: all js files must be in the same directory. I think P@t introduced a new file, theme/Sylvia/local_head.tpl in which you may write something like:

Code:

{known_script id="jquery.tipTip" src=$ROOT_URL/$themeconf.js_dir|@cat:"jquery.tipTip.minified.js" }

P@t will tell more precisely.

About images:

Code:

$ cat Sylvia/themeconf.inc.php 

<?php
$themeconf = array(
  'theme'         => 'Sylvia',
  'parent'        => 'default',
  'icon_dir'      => 'theme/Sylvia/icon',
  'mime_icon_dir' => 'theme/Sylvia/icon/mimetypes/',
);
?>

o inheritance with several level?

P@t told me : no limit.

o directory mail shoud not be on template directory (like include) / and mails/images in icon/mail or images/mail?

P@t told me that mails are in the TODO list

o directory on default theme and other must be the same?

hum? what do you mean? I don't see the changes you made :-/

Offline

 

#6 2010-03-12 00:04:15

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

VDigital wrote:

1 - Template-extension

I wonder if it's really necessary to have template-extension + theme inheritance at the same time. It fills the same function, it may confuse users.

But we can keep template-extension the way they are today and decide later about theme.

VDigital wrote:

2 - Local-layout

There are several local-layout:
./template/yoga/local-layout.css
./template-common/local-layout.css

Adding a local theme is easier to understand in my opinion.

3 - Themeconf.inc.php changes

Sylvia/themeconf.inc.php before:

Code:

<?php
$themeconf = array(
  'template' => 'yoga',
  'theme' => 'Sylvia',
  'icon_dir' => 'template/yoga/theme/Sylvia/icon',
  'admin_icon_dir' => 'template/yoga/icon/admin',
  'mime_icon_dir' => 'template/yoga/theme/Sylvia/icon/mimetypes/',
  'local_head' => '
<!--[if IE]> 
        <link rel="stylesheet" href="template/yoga/theme/Sylvia/theme-ie.css" type="text/css">
<![endif]-->
  ',
);
?>

Sylvia/themeconf.inc.php after:

Code:

<?php
$themeconf = array(
  'theme'         => 'Sylvia',
  'parent'        => 'default',
  'icon_dir'      => 'theme/Sylvia/icon',
  'mime_icon_dir' => 'theme/Sylvia/icon/mimetypes/',
);
?>

+ Sylvia/local_head.tpl :

Code:

<!--[if IE]> 
        <link rel="stylesheet" href="{$ROOT_URL}theme/Sylvia/theme-ie.css" type="text/css">
<![endif]-->

4 - CSS consequences

None I think. P@t will confirm.

5 - Impacts on migration

All existing themes will need to be reorganized for compatibility. But it's not a really hard task compared to the improvement. Considering the low number of existing themes, no probleme for me to help theme creators for new organization.

What will happen to 2.1 delivery?

What do you mean?

Does that mean it will be postponed for a medium size period of release candidate?

No real change. This new architecture will save time on the theme manager creation (+ piwigo.org/ext adaptation)

Offline

 

#7 2010-03-12 10:24:13

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

questions from P@t:

P@t wrote:

What should we do about local-layout.css files? I'm in favour of removing them...

I think we should remove them to avoid the "10 ways to do the same thing" effect.

I will write a documentation to explain how to convert a local-layout.css into a local theme.

Offline

 

#8 2010-03-12 10:36:23

tosca
Former Piwigo Team
Cévennes (France)
2006-09-23
567

Re: New architecture for themes

plg wrote:

... to avoid the "10 ways to do the same thing" effect.

+1


My galleries : Photos, Watercolours, Recipes

Offline

 

#9 2010-03-12 10:49:12

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

Currently, the theme "default" looks like this.

I think it's a good thing "Sylvia" is not the default theme at architecture level (but we keep Sylvia as the default theme at user level).

The "default" theme is really "simple". What about using the content of "clear" instead? (then we remove "clear" of course)

Offline

 

#10 2010-03-12 20:25:45

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
7207

Re: New architecture for themes

I think it's a good idea if we can simplified the structure Piwigo

This can allow the release of more theme


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 

#11 2010-03-12 22:11:09

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

I had a short reply from saimon (simple/* and montblanc themes developer) by email:

saimon wrote:

I gave a quick look to the forum yesterday, but I wanted to to take time for reading in depth before giving my opinion ;-). At first sight, it seems great!

On 11/03/2010 22:48, plg wrote :
> I'm not sure you would imagine such a consequence to your post about themes in Dotclear ;-)

absolutely not, and even more I didn't think you would go so fast!

Offline

 

#12 2010-03-12 22:15:01

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

I also had a short reply by grum (gally template developer, among other things)

grum wrote:

I read the forum topic very quickly this morning. Impacts are not that small, but without searching more deeply I have difficulties to see the consequences. The better is to commit now, then once done, it will be easier to see what may be wrong.

In the worst case, if the solution doesn't fit, we can also go back to the previous state.

Offline

 

#13 2010-03-12 22:16:22

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

Tonight, I'm working with P@t to commit all this new stuff.

Offline

 

#14 2010-03-12 22:25:23

saimon
Member
2006-12-04
184

Re: New architecture for themes

really great ! (you already know that I am an adept of the KISS principle ;-)).

Offline

 

#15 2010-03-13 01:03:32

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: New architecture for themes

[Bugtracker] ticket 1502

[Subversion] r5123 => I made the commit, but P@t made all the preparation (I made the commit to make sure we don't lose the Subversion history of moved files, I was not sure TortoiseSVN would be as safe as SVN command line)

Offline

 
  •  » Engine
  •  » New architecture for themes

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact