[pmwiki-users] conditional parts in skin

H. Fox haganfox at users.sourceforge.net
Mon Feb 13 15:35:57 CST 2006


On 2/13/06, noskule <noskule at gmx.net> wrote:
>  hi list
>  what is the best way (for future version 2.1) to include/exclude parts of
> the skin, depense of pageactions?
>
>  I would like to inculde/exlude part of the skin  depense if the users has
> the right to read, edit, upload,  otheraction. .. .
>
>  I did see several solutions, but what is the best one.  I cant use
>       <!--markup:(:if auth read:)somthing(:ifend:)-->
>  cause i need a diffrent styling and the wikibehavior like questionmark for
> nonexisting pages shouldnt apear .
>
>  Currently I'm using UserAuth but I will switch to AuthUser if 2.1 is
> releasd. . . ..

In skin.php you can do

$page = RetrieveAuthPage($pagename, 'read', false, READPAGE_CURRENT);
if (@$page['=auth']['read']) { # visitor has read permission }
if (@$page['=auth']['edit']) { # visitor has edit permission }
etc...

so you can do, for example,

   if (!@$page['=auth']['edit']) SetTmplDisplay('PageFooFmt', 1);

which says "if the visitor isn't authorized to edit, include the
'PageFooFmt' chunk of the template.  In the template you'd have

   <!--PageFooFmt-->
   (Whatever you want to include...)
   <!--/PageFooFmt-->

Hagan




More information about the pmwiki-users mailing list