Recent Changes - Search:

PITS main list

edit sidebar

Main sidebar

PmWiki

pmwiki.org

01126

Summary: ability to create custom pages for ?action=attr
Created: 2009-07-24 11:46
Status: Open
Category: Feature
Assigned:
Priority: 54
Version:
OS:

Description: currently it is not possible to add custom messages to ?action=login pages and ?action=attr pages without modifying pmwiki.php. this would be useful on sites where one would like to:

  • provide a password for editing certain pages, or for new users,
  • provide a warning to creators of groups who haven't yet made their own personalized password (easy way is to check for the presence of GroupAttributes)
  • the ability to simplify the GroupAttributes?action=attr page by hiding certain fields from non-'admin' users , i.e. the 'upload' and 'attr' permission fields
  • provide instruction on a GroupAttributes page explaining the purpose of each of the four passwords (i think 'attributes' is the least intuitive for new users)
  • provide informative messages about proceeding, before proceeding, etc.

i currently have hacked my pmwiki.php, commenting out the functions involving the login & group attributes screens/prompts, and supplying my own modified version in config.php. this is a change i have to reinstate with every new pmwiki version; it would be better i think to instead have a page (perhaps Site.LoginForm and/or Site.AttrForm) where i can include text above the password prompt.

i asked about this once on the MailingList and this was the response i got from Pm:

2008-05-02 07

The ?action=attr page is one of those few remaining areas where we don't use a wiki page to describe what appears in the page. Instead, it's handled via the $PageAttrFmt variable and the PrintAttrForm() function.

I've done some experiments with converting ?action=attr to use a wiki-based form, but haven't committed anything I like yet.

Pm

thanks! overtones99 July 24, 2009, at 11:47 AM


The login form is in the page Site.AuthForm on your own wiki, and you can change it. About the custom message in the ?action=attr form, you can set whatever message you like in the $PageAttrFmt variable -- you should be able to read a wiki page in it with such a snippet near the end of config.php:
if($action=='attr'){
$p = ReadPage('Site.AttrForm', READPAGE_CURRENT);
$PageAttrFmt = MarkupToHTML($pagename, $p['text']);
}
You shouldn't ever need to modify pmwiki.php, you set in config.php something like:
$HandleAttrFmt = array(&$PageStartFmt,&$PageAttrFmt, 'function:MyPrintAttrForm',&$PageEndFmt);
where MyPrintAttrForm() is your own function replacing PrintAttrForm(). --Petko July 24, 2009, at 01:15 PM

oops. yes, i remember now it's just ?action=attr that was bugging me, not ?action=login. i'll take a look at this regarding patching pmwiki.php externally. thanks overtones99 July 24, 2009, at 01:29 PM

hi Petko - i've tried both suggestions, and neither is working.
1.
if($action=='attr'){
$p = ReadPage('Site.AttrForm', READPAGE_CURRENT);
$PageAttrFmt = MarkupToHTML($pagename, $p['text']);
}
in this case, if i put what you posted above at the bottom of my config, then the whole ?action=attr page breaks. if i don't call MarkupToHTML, then it seems to work, but then that rules out any chance of actually using 'Site.AttrForm' to format some instructions...

2.
$HandleAttrFmt = array(&$PageStartFmt,&$PageAttrFmt, 'function:MyPrintAttrForm',&$PageEndFmt);
i renamed the modified PrintAttrForm function that i had been successfully using before to MyPrintAttrForm, and tried calling both it and the above line at the bottom of my config. the page worked, but nothing happened, and the original/default ?action=attr appeared, not the new one. it doesn't seem to be calling the function at all.

ideas? do these both need to be wrapped in something else?

thanks, overtones99 July 24, 2009, at 07:06 PM

Sorry, I was wrong with the first one, and the second is a PmWiki bug which will be fixed for the next version. So, 1.:
$PageAttrFmt = 'page:Main.AttrForm'; # no if(), ReadPage() etc.
2. should work in 2.2.5, or in the latest code from subversion. --Petko July 24, 2009, at 08:13 PM


Great! thanks Petko! super fast! i'll look for it in the next version (as i've never done svn before). i've added a preliminary page to the Cookbook explaining... CustomAttrForm
overtones99 July 25, 2009, at 07:13 PM

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 11:56 AM