I was just wanting to inquire if there was some philosophical reason
why that was avoided... like too complex for new users or some other
reason that had to do with module support.
I was envisioning something in _config.php like
SSViewer::addTemplateComponents('Header', 'Sidebar')
On Thu, Dec 16, 2010 at 1:09 PM, Hamish Campbell <HN.Ca...@gmail.com> wrote:
> I think this would be an excellent feature!
>
> --
> You received this message because you are subscribed to the Google Groups
> "SilverStripe Core Development" group.
> To post to this group, send email to silverst...@googlegroups.com.
> To unsubscribe from this group, send email to
> silverstripe-d...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/silverstripe-dev?hl=en.
>
It would definitely be nice to make it easier to arbitrary folders like "Layout" and "Content". I'm not sure if automatically attaching every subdirectory of templates in this way would be the best idea, though, because it might lead to unexpected behaviour - would you expect $Includes to be usable in your template?
The ability to have arbitrary subfolders for organising your templates would also add a little bit of confusion. Would "templates/Layout/MemberPages/MemberSignUp.ss" be rendered to $Layout or $MemberPages? Of course, the easiest resolution here is just to pick a convention and stick with it; my initial thoughts would be that this is rendered to $Layout.
Another alternative is to have a separate template code, for example, <% subtemplate Layout %>, rather than $ layout, and that makes it clear that you're expecting to find a Layout subdirectory. However, this would necessitate a tag like <% if_subtemplate Layout %> or <% if subtemplate Layout %> in order to conditionals around them.
I know that Hamish Friedlander had gone pretty far with a rewrite of the template engine so hopefully that will make it easier to make any necessary changes.
Thanks,
Sam
-------
Sam Minnée | Chief Technology Officer
SilverStripe
http://silverstripe.com
Phone: +64 4 978 7334
Skype: sam.minnee
Here's my vote (which balances the trade offs to my liking)
- subfolders: personally, I don't really see the need, for all by the
very largest of sites. I think the topology of actual page types
would be limited enough and there are other ways to vary content at
that granular a level... I doubt I'd ever miss it.
Having said that, if we feel we need it, I would agree
/Foo/Bar
would only be visible only within a /Foo template and not globally.
-Includes would remain as they are (a special case), but could be
extended to be recursive as well, so /Foo/Includes would contain
includes visible only to a template in /Foo.
Also, if I provided a simple one level extension, would you all
consider it for 2.5? or is this long term only? By this I mean just
an SSViewer::extendTemplates("Header", "Sidebar") which was non
recursive and just added to the current functionality.
Hamish, what about your rewrite? Could it help?
For the, the biggest hassle with templates is to have to check where
the templates lives (module, theme or theme_module). For large sites,
the includes folder can also get rather messy, and for that
sub-folders may help. For the layout folder I think I would prefer to
keep all page types into one folder.
Another thing for me is that we keep it simple. It is wonderful to be
able to have SS novices (with lots of general front-end experience) be
able to work on the theme folder.
- Nicolaas
To be clear, the issue of having "flexiblity of folders" like you and
the other contributor above are suggesting, is a completely separate
issue and not the one that I'm suggesting we solve. I think in
practice it would very rarely be an issue.
The main issue is that there should be multiple, app defined templates
available... not just "Layout" and "Content" which is what SSViewer is
currently hard-coded to support. I'm suggesting that either
1) There is a way to specify others, like
SSViewer::AddTemplatesPlaceholders("Header", "Sidebar"
or
2) Anything that ManifestBuilder finds will automatically be
accessible in the templates under its folder name.
Sam and others have rightly pointed out that there are several ways to
go, with the issue of what to do with nested layers...
Sam's suggestion is that templates in say
/Layout/UpperArea
/Layout/LowerArea
be only visible within templates that are in /Layout. That uses the
files system to define and reflect the scope of the template, as it
currently does.
You are hilighting another issue, which is that you would like to be
free of the limitation of where templates have to live and you'd like
to organize them into subfolders as you like. This is potentially a
competing concern. If in fact there is agreement that this is an
issue, and something we should solve (which I'm a bit skeptical about,
actually), then we could perhaps have a hybrid solution:
We only have 1 level of template variables, so
/Layout
/Content
/Sidebar
/Header
could all be there at the top level, and then the the parser just
treats all the subfolders as flavors of that template, like so
/Layout/About/
/Layout/Programs/
/Layout/Media/
would all be treated as the same namespace, similar to how mysite/code works.
Personally I am with Sam, and think that having a generalized,
recursive solution is the cleanest and most useful way. Having a
hybrid system whereby new templates are only definable through the
filesystem (or config file) at the top level, and then can be
organized in subfolders has potential for confusion, and takes away
some useful flexibility, all the while solving a "problem" that very
very few sites would actually have.
I hope this clarifies the conversation a bit, because these really are
separate and somewhat competing concerns.