[pmwiki-users] Templates for new pages
Tom Holroyd
tomh at kurage.nimh.nih.gov
Wed Mar 2 17:46:50 CST 2005
Patrick R. Michaud wrote:
> The tricky part to this (a dropdown list of templates) is getting the
> "insert template option" to display even if someone has customized
> $EditPageFmt.
Well, if someone is going to customize $PageEditFmt, they may or may
not want to include the template functionality, but I see your point.
Here are some more ideas.
Often one wants to "add a page like this" to a list. It's a two step
processes; adding to the list, and adding the page.
So, on the list page, you customize $LinkPageCreateFmt like this:
$LinkPageCreateFmt = "<a class='createlinktext'
href='\$PageUrl?action=edit&template=ItemTemplate'>\$LinkText</a>";
(where I have omitted the '?' for clarity).
Then you just add the new pagename to the list, like
* TheNewItem
and save the page. Then when you click on the link, it automatically
loads the template into the text field, via something like
if (isset($_GET['template']))
$new['text'] = GetTemplatePage($_GET['template']);
in HandleEdit(), just before calling the EditFunctions, where
GetTemplatePage is basically
function GetTemplatePage($pagename) {
Lock(1);
$p = RetrieveAuthPage($pagename,'read');
if (!$p) Abort("?cannot source $pagename");
return $p['text'];
}
Another approach is to customize $DefaultPage or $PageNotFound for the
list page to be something like (:include template:). Then the edit
link would work automatically without needing to add arguments to ?action.
By the way, how do you customize a variable for one page? I guess you
could do it in the GroupHeader using conditional markup based on the
PageUrl, or perhaps there is a directive that sets a variable?
--
Dr. Tom Holroyd
"A man of genius makes no mistakes. His errors are volitional and
are the portals of discovery." -- James Joyce
More information about the pmwiki-users
mailing list