Last modified: 2011-04-14 15:10:37 UTC
I want to define page layout templates - not the current Templates that are more like macros, but rathera common page layout that I can associate with pages, for example with a new namespace "Layout:", [[Layout:MyLayoutName]] or perhaps indirectly by associating a layout with a category, or as a choice in the page editor. For example, I may want to automatically include a header, navigation, and footer template on a subset of pages, for example, for articles about Eclipse. I may define a layout, called [[Layout:Eclipse]], as follows {{Eclipse-heading}} {{Page:content}} {{Eclipse-navigation}} {{Eclipse-footer}} However, I don't want to have to include these templates in each and every page in the Eclipse category. Rather, I would like to create a [[Layout:Eclipse]] page layout and by referencing [[Layout:Eclipse]] on these pages (similar to how one references categories), it will use that page layout; i.e. automatically include the heading, navigation, and footer. Such layouts may contain <div> or <table> or other layout markup, whether (restricted) html or wiki. (I'm suggesting one implementation; other implementations for assiging a page layout to a page are also possible.) When a page is previewed or saved, its body is substituted where {{Page:content}} (or some other meaningful marker/variable) appears, and the other templates/markup inserted as if they were on the original page. User's editing such pages would not have to explicitly include this boilerplate, and I could change this page layout template once and all pages which use it would render with the new layout. Only one page layout is needed per page, although I can see how it may be possible/desirable to nest them via a Decorator pattern; the output of applying one page template then becomes the {{Page:content}} for the next. This would be tricky; you would not want to reformat/reinterpret the text as markup. In addition, some layouts may themselves reference other layouts. (Beware of cycles, though!) Finally, I would expect to have a default page layout for the site; i.e. [[Layout:default]] or [[Layout:site]]. For example, there is an implicit page layout template already which includes MediaWiki:Sitenotice and MediaWiki:Tagline. I would like to make it more explicit and customizable and allow different pages or categories to have their own custom page layouts (either replacing or augmenting other layouts).
I may be being dense, but couldn't your example be just as easily implemented with a Template:Eclipse, consisting of {{Eclipse-heading}} {{{content}}} {{Eclipse-navigation}} {{Eclipse-footer}} To then be called with {{(subst:)Eclipse|content=An eclipse is a rare event...}}?
My proposal would all changing the template after it has been instantiated, and all articles using the template would automatically update. Using subst "erases" the link to the template. Also, full page content is often too large/awkward to fit into a template call.
In that case you could not subst the template. It's not particularly awkward - all you have to do is have a first line with "{{Eclipse|content=", and a final line with "}}".
That does not work if the content contains other template invocations or tables. For example, see http://www.mediawiki.org/wiki/User:DavidBiesack/template which I use in http://www.mediawiki.org/wiki/User:DavidBiesack/test Note how the table is lost
I stand corrected. That seems a bit rubbish: time to dive into the parser and make tables work properly :-)