OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Custom Navigation Bar in OCS

Are you responsible for making OCS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, michael, John

Forum rules
What to do if you have a technical problem with OCS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

Custom Navigation Bar in OCS

Postby gmattei » Sat Mar 14, 2009 11:01 am

Hi, I would like to customize the navbar (header.tpl) in order to restrict the navigation according to user privileges.
I changed the code inserting an if-else syntax, as follows:

Code: Select all
<div id="navbar">
{if $isUserLoggedIn}
{* logged user *}
   {if $isSiteAdmin or $isSchedConfManager or $isConfManager}
{* then original navigator bar *}
   <ul class="menu">
      <li><a href="{url conference="index" schedConf="index" op="index"}">{translate key="navigation.home"}</a></li>
      <li><a href="{url page="about"}">{translate key="navigation.about"}</a></li>
      {if $isUserLoggedIn}
         <li><a href="{url page="user"}">{translate key="navigation.userHome"}</a></li>
      {else}
         <li><a href="{url page="login"}">{translate key="navigation.login"}</a></li>
         <li><a href="{url page="user" op="account"}">{translate key="navigation.account"}</a></li>
      {/if}
      <li><a href="{url page="search"}">{translate key="navigation.search"}</a></li>
      {if $currentConference}
         {if $currentSchedConfsExist}<li><a href="{url schedConf="index" page="schedConfs" op="current"}">{translate key="navigation.current"}</a></li>{/if}
         {if $archivedSchedConfsExist}<li><a href="{url schedConf="index" page="schedConfs" op="archive"}">{translate key="navigation.archive"}</a></li>{/if}
         {if $enableAnnouncements}
            <li><a href="{url page="announcement"}">{translate key="announcement.announcements"}</a></li>
         {/if}
         {call_hook name="Templates::Common::Header::Navbar::CurrentConference"}
      {/if}
      {foreach from=$navMenuItems item=navItem}
         <li><a href="{if $navItem.isAbsolute}{$navItem.url|escape}{else}{$navItem.url|escape}{/if}">{if $navItem.isLiteral}{$navItem.name|escape}{else}{translate key=$navItem.name}{/if}</a></li>
      {/foreach}
   </ul>
   {else}
{* restricted navbar for the others *}
   <ul class="menu">
      <li><a href="{url conference="index" schedConf="index" op="index"}">{translate key="navigation.home"}</a></li> 
      {foreach from=$navMenuItems item=navItem}
         <li><a href="{if $navItem.isAbsolute}{$navItem.url|escape}{else}{$navItem.url|escape}{/if}">{if $navItem.isLiteral}{$navItem.name|escape}{else}{translate key=$navItem.name}{/if}</a></li>
      {/foreach}
   </ul>
   {/if}
{else}
{* non logged user *}
   <ul class="menu">
      <li><a href="{url conference="index" schedConf="index" op="index"}">{translate key="navigation.home"}</a></li> 
      <li><a href="{url page="login"}">{translate key="navigation.login"}</a></li>
      {foreach from=$navMenuItems item=navItem}
         <li><a href="{if $navItem.isAbsolute}{$navItem.url|escape}{else}{$navItem.url|escape}{/if}">{if $navItem.isLiteral}{$navItem.name|escape}{else}{translate key=$navItem.name}{/if}</a></li>
      {/foreach}
   </ul>
{/if}
</div>



From the "non power" user side everything seems to work and I find only the restricted navbar, but if I log in as a site administrator as soon as I enter one of the original menus of the navbar (which are correctly in their original place, e.g., "About" or "User Home") I find only the "restricted version" of the navbar as if I were a normal user.
Is there a way to solve this?
Thanks in advance.
GM
gmattei
 
Posts: 7
Joined: Thu Mar 05, 2009 4:03 pm

Re: Custom Navigation Bar in OCS

Postby mcrider » Mon Mar 16, 2009 3:55 pm

Hi gmattei,

The $isSiteAdmin/$isSchedConfManager/$isConfManager variables aren't globally accessible to every template, so that first 'if' statement will return false in some cases. You could make them global by adding this code to classes/template/TemplateManager.inc.php in the TemplateManager() function (best to put it in around line 93, under the 'isUserLoggedIn' definition).
Code: Select all
$this->assign('isSiteAdmin', Validation::isSiteAdmin());
$this->assign('isConfManager', Validation::isConferenceManager());

Note that there is no check for isSchedConfManager, but it shouldn't be necessary anyway (a sched conf manager has the conference manager role).

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: Custom Navigation Bar in OCS

Postby gmattei » Tue Mar 17, 2009 4:22 am

Hi Matt,
many thanks for your help: everything is now working perfectly.
Kind regards,
Giovanni
gmattei
 
Posts: 7
Joined: Thu Mar 05, 2009 4:03 pm


Return to OCS Technical Support

Who is online

Users browsing this forum: No registered users and 2 guests