From: Todd M. <nil...@ne...> - 2003-01-14 19:52:17
|
The attached patch adds page template support to phpwiki when creating a page. When you initially edit a page that did not previously exist, it will check for a templatename parameter. If it exists, it will use it's value as a pagename to use for the default content of the page. It also does variable substitution on the template page content for {pagename} and {sourcepage}. Also in the patch, when viewing a nonexistant page, you see a message saying the page does not exist, but when editing such a page for the first time without a template, it defaults to the usual 'Describe [pagename] here' content. A plugin called TemplateForm is also provided, which let's you insert a form into a page for page creation. You can specify a particular template page to use, or let it show a drop down box of templates. One example using this is Categories. If you add the following snippet to the end of CategoryCategory: ========================================================= -- Create new category: <?plugin TemplateForm template=CatTemplate buttontext="Create Category" ?> ========================================================= and add the following pages: CatTemplate: ========================================================= Pages in category [{pagename}]: <?plugin BackLinks noheader=1 ?> Create new page in this category: <?plugin TemplateForm template=CatPageTemplate ?> -- CategoryCategory ========================================================= CatPageTemplate: ========================================================= Describe [{pagename}] here. -- [{sourcepage}] ========================================================= Now, category creation, and creating pages within a category just became much simpler. If this is worth pursuing, other useful features should be easy to add: * have a DefaultTemplate so you can customize the default content for new pages for an entire site * add a template parameter to the Calendar plugin, so you can have boilerplate for calendar entries. Comments? [Note: patch is against current CVS] -- Todd Mokros <nil...@ne...> |