How to override a popup

I’m trying to develop a custom popup view for a custom module
stumbled upon a solution and thought I would share it.

first, you have to make sure that the base module folder has a controller in my case since I was using a custom module, I had to add a controller to
my base module folder modules//controller.php the controller can be empty in the base module folder since you will be using the
custom module to override it.


class 	<module>Controller extends SugarController
{
	
}

Add the controller in custom/modules//controller.php make sure your custom controller has the following naming convention
and make sure it inherits the base module controller


class Custom<module>Controller extends <module>Controller
{
	public function action_Popup()
	{
		$this->view = 'Popup';
	}
}

Now we need to add the view that we call in our custom controller in custom//views/ add view.popup.php
make sure you inherit from SugarView and you can customize what you want displaying in your popup through
editing the display function


if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class Custom<module>ViewPopup extends SugarView
{
    public function display()
    {
        echo 'output';
    }
} 
2 Likes

thanks for pointing in the right direction, one small correction (without which it didn’t work for me at least) is to require the system popup view file inside the last file and extend the popup view (not sugarview)

Following worked for me:


<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once ("include/MVC/View/views/view.popup.php");

class [NAME_OF_YOUR_MODULE]ViewPopup extends ViewPopup
{

    public function display()
    {

        // do stuff

        parent::display();
    }


}