Monday, May 13, 2013

Creating custom view for SugarCRM

Hi,
From last few days, i was active on SugarCRM product and searching for the customizing its properties.
I found out how to customize the view layer.

Step 1: Create Custom module in customer dir
i.e. custom/modules//controller.php

controller.php file responsible for the redirection of view file.

ex:


class your-module-nameController extends SugarController {

    public function action_test() {
        $this->view = "welcome";  //call for the view file in views dir
    }
}


Step 2: create views dir i.e. custom/modules//views/view.welcome.php

code:

class your-module-nameViewWelcome extends SugarView {
     function
your-module-nameViewWelcome(){
         parent::SugarView();
     }


    public function preDisplay(){
        $this->dv->tpl = 'custom/modules//tpl/welcome.tpl';
    }


    function display(){
         $smarty = new Sugar_Smarty();
         parent::display();
         $smarty->assign("welcome", 'welcome');
         $smarty->display($this->dv->tpl);
    }
}

Step 3: create tpl file inside custom/modules//tpl/welcome.tpl

{ $welcome } To TPL Page


your will access the page via:

http:///module=&action=test

then you will see your template.

I hope this information would help you :)