Create Different View Per Customer



# 1 > Create Helper

=> Create Helper (app/View/Helper/GeneralHelper.php)
=> Create Function (defaultOrDirect())
=> Add following inside the function 
function defaultOrDirect($company_id, $link) {
     if(file_exists(APP.‘View’.DS.‘Elements’.DS.‘companies’.DS.$company_id.DS.$link.‘.ctp’)){
        return ‘companies’.DS.$company_id.DS.$link;
   } else{
       return ‘companies’.DS.‘default’.DS.$link;
   }
}

 


# 2 > Create Element Folders

=> Create Folders in Element

  • View/Elements/companies/default.ctp
  • View/Elements/companies/index.ctp
  • View/Elements/companies/5/index.ctp (another folder for a different customer)

# 3 > Modify index page

=> Pages/index.ctp, add the following
<?= $this->element($this->General->defaultOrDirect($companyId, ‘index’)); ?>


# 4 > Modify App Controller
=> In APPCONTROLLER add the following in beforeFilter
$this->set(‘companyId’, 5);

# 5 > Viewing Page

Now when you navigate to
Pages/index in your browser
You will see the content from Element/companies/5/index
NOT ‘default’.
but if you change ‘companyID’ to any other number you will now see Elements/companies/default/index

 


Other Instructions

Below are many other instructions that show you how to use your UpdateCase application