Postings

xaraya
Browse in : All > subjects > xaraya

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xd and user-summary-[publicationtype].xd. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles The templates will get the extension .xt there.

Title: Admin, Editors, and Webmaster menus in my sites

Author: linoj

Date: October 01, 2006 1:53:13 PM or Sun, 01 October 2006 13:53:13

Summary: How I configure my sites with separate Admin, Editors, and Webmasters menus. These can be selectively shown using privileges.

Body: 

The default built-in administrators menus in Xaraya provide access to all the modules' configuration functions. This is great for the website developer. But other kinds of admin users, like Editors and Webmasters, don't need these plethora of options, so I also provide a separate Editors menu and Webmaster menu with quick links to common admin functions.

My strategy of this has been evolving, and improves a bit with each new site I develop.

Present features include


 

Note, this is more a convenience than a security thing, since most people will avoid clicking on things and changing things they don't know about, especially if the instructions are clear where they can and should click. To actually restrict access to specific admin config pages, on a per module basis, can still be accomplished using the Privileges system.

Create the Admin Menu Blocks

The admin menus on the right side are menu blocks (or any other blocks you want), in a blockgroup named "admin". If you don't have one already, create a blockgroup named "admin". Then create one or more base/menu blocks, such as editorsmenu (title "Editors Menu"), and webmaste (title "Webmaster"), etc. I also add a roles/online block ("Who's Here").

The Editors menu might contain, for example, a link to "Add News" ("?module=articles&type=admin&func=new&ptid=1"). The Webmasters menu might include a link to "Edit About Page" ("?module=xarpages&type=admin&func=modifypage&pid=1"). And so on.

The full admin menu is a block type base/adminmenu. It's presented as a horizontal menubar with dropdown menus using the verticallistbycats-top.xt template. No need to create a block instance, however, as we'll create it on the fly using the <xar:block> tag.

Is User an Admin?

At the top of the page template, mytheme/pages/default.xt, we first determine whether the current user gets to see the admin menus. This can be done in a number of ways. I use the Cheap Trick method (Using privileges to display content by user or group, http://www.xaraya.com/index.php/documentation/306 ).

That is I create an empty priv named "showAdminMenusFlag", and assign it directly to any users, or groups that are allowed to see the admin menus.

<xar:if condition="xarModAPIFunc('roles','user','checkprivilege', array('uid' =&gt; xarSessionGetVar('uid'), 'privilege' =&gt; 'showAdminMenusFlag'))">
<xar:set name="showAdminMenu">1</xar:set>
</xar:if>

Be sure to add the showAdminMenusFlag to the Administrators roles group. And it is up to you to ensure any other users or groups that receive this flag also have privileges to view the menu blocks and admin functions you are granting. 

Content Wrappers

In the page template in my theme, mytheme/pages/default.xt we put the admin navbar on top. And we make room for the right side admin menus using div wrappers -- wrap the actual page body in an #outer-wrapper div, and wrap all of that inside an #admin-wrapper. This way the admin menus outside are the page and do not disturb their formatting.

<xar:if condition="!empty($showAdminMenu)">
<div id="xb-admin-wrapper">
<xar:block module="base" type="adminmenu" template="mainnavbubble;top" />
<div id="xb-admin">
<xar:blockgroup name="admin" id="admin" />
</div>
</xar:if>
<div id="xb-outer-wrapper">
... actual page content...
</div>
<xar:if condition="!empty($showAdminmenu)">
</div>
</xar:if>
</body>

 

The styles for these div's are defined as follows:

#xb-admin-wrapper {
margin: 0 140px 0 0;
background-color: #EEE; /* browser background color */
}

 

#xb-admin {
position: absolute;
right: 0;
background-color: #ddd;
border: 1px black solid;
width: 130px;
}


#xb-outer-wrapper {
background-color: #FFF; /* page background color */
width: 720px; /* for fixed width layouts */
}


In the case of fluid-width layouts, the outer wrapper might look like this: (note, this won't work in IE, so for IE I make it fixed width anyway)

#xb-outer-wrapper {
background-color: #FFF; /* page background color */
/* following lines for fluid width */
margin: 0 auto;
min-width: 600px;
max-width: 1200px;
/* ie doesnt support min width, hack it fixed */
width:auto !important;
width: 720px;
}



 

 

 

Notes: 

More fields may be available via dynamicdata ..

Last modified on Oct 01, 2006 5:03:33 PM by linoj

There are no comments attached to this item.

Post a new comment

BBCode Actions : Close Tags

Name : Anonymous


Keywords :

  • admin