Re: Template layers
Reply #15 –
Yup. And so it was with us too, the road Elk is walking down is much the same as the path we took ourselves. First making it so that you don't need both the _above and_below pairs (but not changing flow order), then allowing multiple items in the main area, and ultimately turning into the beast you see before you, which is really only an extension of the concept of template layers, just taken several steps further.
I suggest it here mostly as a 'we had the same problem, this is what we did, perhaps it is of use to you to consider this direction, though I suspect you'll find your own path that does its own bold and imaginative thing'.
Re: Template layers
Reply #19 –
Or, you know what be a lot nicer than writing yet another template system? Using a pre-existing one. I am partial to handlebars (and it compiles to the root language so it is quite fast). The current system could have templates under the theme's control if the themes were made as classes and used an autoloader or use some naming conventions and create your own procedural autoloader via something like function showTemplate($template) { // break down the name and find what file to load }
Since the "theme" is the view in Elk/SMF architecture, you could allow the view to make those changes and not be "wrong". If you implemented a proper MVC architecture and abstracted the template system from the view, it would be very wrong to do "layer" manipulation at the template level.
Re: Template layers
Reply #20 –
I love your little sermons about how everything is wrong and that you know best. What we have and what was suggested is merely one option. It is an option that works very well for us and does exactly what we want it to do and meets our requirements in terms of things like plugins.
When you've actually implemented what you're talking about, and can demonstrate it in practical use, come talk to me.
Re: Template layers
Reply #21 –
Fair 'nuf. Though, I wasn't talking about Wedge or what was already done. I was talking about the possibility of writing yet another template system here.
Re: Template layers
Reply #25 –
As far as theme portability is concerned, no-one worries about SMF themes not working in IPB or XenForo themes not working in SMF, for example... or even YaBB themes not working on SMF... so why should we worry about keeping compatibility as such?
Re: Template layers
Reply #26 –
Ok, had some inspiration to code in some of the ideas discussed here in my fork project. I landed on a two-way approach though, with Boardindex as an example I converted that to 3 extra layers (newsfader,boards and infocenter)and made it such that layers don't need "above"/"below" - and that they are added to an array, easily accessible to mods. I also added a plugin option where a plugin can specify which layer it wants to be inserted after(need to write an interface for adding plugins now lol). Since the major templates will have a above/below first, there's no need for inserting it "before" a layer,only "after".
Next I added a check to see if the theme wants its own layout of layers, which it starts off by adding that layout to the template_init() of for example Boardindex. If it exists it will use that instead of the normal layer array.But, it checks against the layers array to see if any specified by the theme are actually turned off. It also adds plugin specific layers onto a designated area and finally allow the theme with its own custom layers/subtemplate functions. The reason i want this layout option is that I want all subtemplates(which are put in layers) to work on their own, more or less, and by adding the layout code outside of them I keep that versatility. I also use a grid-based CSS so its easy to construct them in the same fashion across themes and sections. If the theme doesn't use a own layout, then it will follow the original ordering of layers, which I also plan to be able to manipulate. But, a layout must not exist or be turned off, for it to be in effect...
For index.template I'm keeping the simplicity of just writing the whole shebang in the existing html/body layers though(with of course linktree and main menu as separate calls) - I feel the need to chop it up is less there than in the other subtemplates, since it stays the same throughout the site.
Re: Template layers
Reply #27 –
Since the best way to define if something is useful, is to actually use it the way it should, I found my method was pretty weak (at least for how I wanted to use it), so I'm now working on improving it a bit.