User tests: Successful: Unsuccessful:
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
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> |
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.
Well, nothing is set in stone here 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
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
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.
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?
Labels |
Added:
enhancement
|
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 ;)
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 correspondingApp
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..).
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
)
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.
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.
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
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.
That'd be cool.
I'd give that a big
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}/*
.
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.
@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.
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?
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
).
We going anywhere with this?
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.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-03-29 17:33:24 |
Closed_By | ⇒ | elkuku |
Why not move template into Apps folder, like
src/App/Text/templates/
?