GemsTracker

GEneric Medical Survey Tracker

User Tools

Site Tools


Sidebar

Quick Links

Main site / download

API Docs
Bug tracker
Demo site
GitHub

Index

devzone:giftbox:changing_header_to_organization_name

Changing the header to organization name

If a user is logged in we will change the default header (project name) to that users' organization name.
This can be achieved in Escort.php.
We need to override the function _layoutProjectName that is in library/gems/classes/escort.php. We copy this function in our own application/classes/[yourproject]/Escort.php:

    /**..........*/
 
class Yourproject_Escort extends GemsEscort implements
    Gems_Project_Layout_SingleLayoutInterface,
    (etc)
{
 
   /**
     * Function called if specified in the Project.ini layoutPrepare section before
     * the layout is drawn, but after the rest of the program has run it's course.
     *
     * @return mixed If null nothing is set, otherwise the name of
     * the function is used as Zend_View variable name.
     */
    protected function _layoutProjectName(array $args = null)
    {
        if (isset($args['tagName'])) {
            $tagName = $args['tagName'];
            unset($args['tagName']);
        } else {
            $tagName = 'h1';
        }
 
        //This is changed: get the userdata and set the switch
        $user = $this->getLoader()->getCurrentUser();
        if($user->hasRole('nologin')){
            //back to default if no user is logged in
            return MUtil_Html::create($tagName, $this->project->name, $args);
        }else{
            return MUtil_Html::create($tagName, $user->getCurrentOrganization()->getName(), $args);
        }
    }
}
devzone/giftbox/changing_header_to_organization_name.txt · Last modified: 2020/03/12 12:06 (external edit)