[Pmwiki-users] Conditionally displaying edit links

Hans Bracker design
Fri Dec 31 02:50:23 CST 2004

On Pmwiki/ConditionalMarkup Steven Leite wrote:
>I'd like to know if it's possible to check if a user is authenticated
>as either "editor" or "admin" (in terms of permission to edit pmwiki
>pages), and then either hide or display the "Edit This Page" link
>depending on if the user is allowed to edit the page or not.

I was musing on this and came up with these scenarios:
Assuming here that we are talking about cosmetic measures, i.e. hiding
a link, an dthat the security measures are dealt with otherwise by
installing passwords etc.

1. an easy option is to hide the edit link on the page itself, i.e
put it in  a corner, make it small, change the font color so it is pale
or even invisible, use some other word perhaps on the footer to act as
the link.

2. another option is to use two different skins: one for just browsing
readers, the other for editing users, using the Cookbook/SkinChange
recipe. The editor's skin can get an obscure name and may be only
available via ?setskin=obscurename.

3. using Cookbook/AuthenticatedAsConditional one could display an edit
link conditionally, by adding to the SideBar or the page or a
GroupFooter for instance:
   (:if authenticated edit :)*[[{$Name}?action=edit |Edit Page]](:if:)
The page template would need to be edited to remove any ?action=edit
from it. Or the footer can be hidden by using (:nofooter:) directive
on the page or a GroupHeader/Footer. Once a user is logged on as an
authenticated editor the edit link will be visible. Perhaps a
LoginPage may be helpful, otherwise adding ?action=edit to the page
url will ask for the edit password.

4. remove or disable the footer, create a custom page called perhaps
Main/EditBar, put all your edit, history etc action links on it, and
use on a GroupFooter page
   (:if authenticated edit :)(:include Main/EditBar:)(:if:)

(:if authenticated ...:) is really smart and very versatile and lets
you add ?action=... links  in many more ways. Thank you MarkS!


More information about the pmwiki-users mailing list