enhancement Success

User tests: Successful: Unsuccessful:

avatar elkuku
elkuku
2 May 2014

This will move the App template files (twig) to a directory of the corresponding App.

This should help in separating the Apps.

Note the config changes

avatar elkuku elkuku - open - 2 May 2014
avatar elkuku elkuku - change - 2 May 2014
The description was changed
Description <p>This will move the App template files (twig) to a directory of the corresponding App.</p> <p>This should help in separating the Apps.</p> <p>This will move the App template files (twig) to a directory of the corresponding App.</p> <p>This should help in separating the Apps.</p> <p><strong>Note</strong> the config changes</p>
avatar piotr-cz
piotr-cz - comment - 5 May 2014

Why not move template into Apps folder, like src/App/Text/templates/?

avatar elkuku
elkuku - comment - 5 May 2014

Not sure what you mean. I believe this is what this PR does - Or do you mean move them all to a common directory, like before?

What is done here is e.g.:
templates/text/article.edit.twig → src/App/Text/tpl/twig/article.edit.twig

The only big difference I see is that I named it tpl and added the renderer type twig

The idea is to have everything that belongs to a specific App in one location.

avatar piotr-cz
piotr-cz - comment - 5 May 2014

This is exactly what I meant, just didn't read pull request correctly.
I personally prefer this pattern: Text/templates/article/view.html.twig (more info here).

avatar elkuku
elkuku - comment - 7 May 2014

Well, nothing is set in stone here :wink: We can even support multiple paths.
Another option would be, since we still use View classes, to put them inside the view where they are used e.g. src/App/Text/View/Article/tpl/twig/article.edit.twig almost like in the CMS..

more info here

This looks quite impressive. I'm going to follow it :wink:

avatar piotr-cz
piotr-cz - comment - 7 May 2014

I must confess, that I'm influenced by Twig in Symfony.

Using format if file name has advantage when switching between them in controller or between renderers:

article/
  view.html.twig
  edit.html.twig
  view.rss.twig

  view.html.mustache
  edit.html.mustache
  view.rss.mustache

As for multiple paths: I'm using application template path for default templates like index.html.twig, menu.html.twig and within a domain just domain templates that reference the application ones. If there is a index.html.twig within domain, it has higher priority.

Would be cool to have installable themes like in the CMS which would take highest priority but that's for the future

avatar b2z
b2z - comment - 8 May 2014

@elkuku

Another option would be, since we still use View classes, to put them inside the view where they are used

That's not a good idea for me personally. Templates should live in one common directory like we have now and in this PR.

@piotr-cz

Using format if file name has advantage when switching between them in controller or between renderers

Good catch. @elkuku what do you think? Since we are using template engine's name in the file names may be we do not need divide them into separate folders and follow @piotr-cz proposed convention?

avatar elkuku elkuku - change - 9 May 2014
Labels Added: enhancement
avatar elkuku
elkuku - comment - 9 May 2014

I agree, separate folders for the formats don't make much sense. Have been moved.

Why not placing them in the View folder I can not understand yet, but I would be happy to see them at least inside the corresponding App folder ;)

avatar piotr-cz
piotr-cz - comment - 9 May 2014

Why not placing them in the View folder I can not understand yet, but I would be happy to see them at least inside the corresponding App folder ;)

DDD says templates are resources and belongs to separate folder within domain (well, we don't follow DDD in JIssues).
One advantage that comes to my mind is that if you'd like to use templates in frontend, you may symlink or copy templates directory to public folder.

Same goes for assets (javascript, stylesheets, images, fonts..).

avatar elkuku
elkuku - comment - 9 May 2014

I think you can create symlinks from/to multiple locations, but well :wink:

DDD says...

OK, I really have to read those red and blue books then (@todo)

avatar b2z
b2z - comment - 9 May 2014

Which pill do you prefer - red or blue? :)))

Best regards,
Dmitry

----- Reply message -----
From: "Nikolai Plath" notifications@github.com
To: "joomla/jissues" jissues@noreply.github.com
Cc: "Dmitry Rekun" bzzjuka@gmail.com
Subject: [jissues] Move App templates to their proper App directory (#346)
Date: Fri, May 9, 2014 17:51
I think you can create symlinks from/to multiple locations, but well

DDD says...

OK, I really have to read those red and blue books then (@todo)


Reply to this email directly or view it on GitHub.

avatar HermanPeeren
HermanPeeren - comment - 9 May 2014

Yes, time-investment with high ROI to read those books (start with one; I'd say the oldest, the blue one, by Evans, with which the term DDD originated), but you won't find anything about templates or resources in those books, because they are about modeling and that has nothing to do with templates etc. I don't understand Piotr's sentence about "DDD says...". You'll find discussions about folder structure in the DDD-community, like in http://verraes.net/2011/10/code-folder-structure/ and http://williamdurand.fr/2013/08/07/ddd-with-symfony2-folder-structure-and-code-first/ . Of course it is important where to place templates etc., but I don't see it as part of building your domain model. If I misunderstood Piotr, please let me know.

avatar piotr-cz
piotr-cz - comment - 12 May 2014

I'm taking back the 'DDD says...' part. I can't find the reference.
However, a resources folder is as place where I'd put templates (and anything that is not php code).

Thanks @HermanPeeren for good read again

avatar b2z
b2z - comment - 22 Jul 2014

Would be cool to have installable themes like in the CMS which would take highest priority but that's for the future

May be we can add simple support for themes in this PR? Something like src/App/Text/tpl/{theme}/*.
Current templates will live in src/App/Text/tpl/default/* folder.

avatar mbabker
mbabker - comment - 22 Jul 2014

That'd be cool.

avatar elkuku
elkuku - comment - 22 Jul 2014

I'd give that a big :+1::wink:

avatar b2z
b2z - comment - 23 Jul 2014

I see only one problem with themes - templates are in App dir. For example I want to make some awesome BT3 theme. Then I should create some bt3 folder inside every tpl folder of every App and inside templates/JTracker also. Like this:

src/App/Text/tpl/bt3/*
templates/JTracker/bt3/*

Sounds a little bit complicated :(

And templates/JTracker/* will not be logical if we will think in terms of /path_to_templates/{theme}/*.

avatar sebastianluckos
sebastianluckos - comment - 31 Oct 2014

I think templates/ folder is misleading as it contains only one template with twig files for different frontend parts. The templates - there should be one more folder in the templates/ maybe JTracker, or default for current.
Why another level? Well because if I want to create new template for the app, than I have to edit current files, which will get overwritten on update (probably wrong here but...). In future we could assign different templates by link params. This folder contains not only visual look, the hardcoded menus and other layout parts are creating need for more than just one.

What I think should be moved from templates/ folder is the language folder, as the frontend files may have different paths but this one should not.

avatar b2z
b2z - comment - 31 Oct 2014

@sebastianluckos so you are against moving templates to App directories?

What I think is that the templates should be App agnostic. That will provide more flexibility of creating different themes. So my proposal is:

templates/{theme}/*.*
templates/{theme}/{app}/*.*

We could store our current templates in the templates/default/**. Theme parameter should be configurable - if it is set, then we could use setTemplatesPaths to register additional theme folder.

avatar sebastianluckos
sebastianluckos - comment - 31 Oct 2014

@b2z I agree, one place for whole template instead of spliting them by App. As for the twig, there are php shortcodes too. Which leads to question about moving it to resources, where would this folder go?

avatar b2z
b2z - comment - 31 Oct 2014

As for the twig, there are php shortcodes too. Which leads to question about moving it to resources, where would this folder go?

What do you mean?

avatar sebastianluckos
sebastianluckos - comment - 31 Oct 2014

In the template/ there is folder with php files. As much as js, css, twig can be placed in resources, I think php should not be there.
I refer to @piotr-cz about the resources.

avatar b2z
b2z - comment - 31 Oct 2014

Ah ok. As I remember it some kind of experiments by @elkuku implementing PHP templates. So these PHP files should be stored along with the Twig files as @piotr-cz stated here.

avatar mbabker
mbabker - comment - 19 Dec 2014

Bring this back up. Between this and #551 there's some good ideas and I think we should follow through on them. One of the possibilities these present is the ability to refactor the "core" app to have a more generic appearance and the main site would still implement the Joomla template. No hacking of the core files necessary, and believe it or not there have been some random comments about being able to use this app elsewhere. Decoupling the Joomla template would definitely help.

Regarding where the layouts get stored, I like the direction this PR is going. If you treat each app as a separate entity, then it should keep its resources within it (where feasible, there are some requirements like web media being installed to a specific path). In one of the Framework apps I'm working on, we enabled layout override support (CMS style thinking) using our default path lookups. This is the priority array (this is implementing a different rendering engine FWIW):

array(
JPATH_ROOT . '/templates/' . $app->getTemplate() . '/layouts/%view%/%name%.php',
JPATH_ROOT . '/src/App/%app%/View/%view%/tmpl/%name%.php',
JPATH_ROOT . '/templates/' . $app->getTemplate() . '/layouts/%name%.php'

The last path is there to support the template root files (like templates/index.twig).

avatar mbabker
mbabker - comment - 12 Mar 2016

We going anywhere with this?

avatar b2z
b2z - comment - 13 Mar 2016

I still think that we should keep the markup in a separate folder with theme parameter:

templates/{theme}/*.*
templates/{theme}/{app}/*.*

All in one place. Designers do not need to search in apps for markup.

Yes, may be our apps should be separate as possible, but they still will not work without the core. So the layouts for all apps could live in one place and this approach is well known and common for users.

avatar elkuku elkuku - change - 29 Mar 2017
The description was changed
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-03-29 17:33:24
Closed_By elkuku
avatar elkuku elkuku - close - 29 Mar 2017
avatar elkuku elkuku - close - 29 Mar 2017
avatar elkuku elkuku - head_ref_deleted - 24 Jun 2018

Add a Comment

Login with GitHub to post a comment