Create new action in custome module.

Hi guys,

I need a new action in custome module, I want to add convert function to the person module.

I create the module by the Studio, but created modul have not controller.php so how can i create the new action in custome module?

Thx for your reply.

AJ

You can simply create the controller file you need. In ‘modules/YourModule/controller.php’ put:


<?php
class YourModuleController extends SugarController{
    //Can now put actions here
    public function action_helloworld(){
        echo "Hello world!";
    }
}

Thank Jim, but this solution I know but it’s not function. The new module was created by the studio.

I create the controller.php with function action_convert and if i call a /index.php?module=hhp_physio&action=convert&record=… (i try &action=Convert too) and system stil write There is no action by that name.

Do you have any idea why the controller.php not function?

Have you enabled developer mode and done a quick repair and rebuild after you added the controller?

Hi Andy, yes I have done that. Can be a problem that his module is created by studio?

Not really, there must be an error in your code thats causing this.

Thx, I’ll try to debbug the code and give some error message, than I past it here with the code.

Hi guys, this is error I get

Notice: Undefined variable: controller in /var/www/html/crm.dev.hhp.de/include/MVC/Controller/ControllerFactory.php on line 81 Fatal error: Call to a member function setup() on a non-object in /var/www/html/crm.dev.hhp.de/include/MVC/Controller/ControllerFactory.php on line 81

and this is a code of my controller.php

class hhp_physioController extends SugarController {
//Can now put actions here
public function action_convert(){
echo “Hello world!”;
}
}

the name of module i hhp_physio.

Just to confirm. You have a modules/hhp_physio/controller.php file with the contents in your last post?

Please bear in mind PHP files should have <?php before class declarations. I.e:


<?php
class hhp_physioController extends SugarController {
    //Can now put actions here
    public function action_convert(){
        echo "Hello world!";
    }
}

If the above still does not work you will have to add some debug or use a debugger in ControllerFactory to find out why it’s not loading your controller.

Thanks,
Jim

Sorry for posting oo a very old topic, But did anyone manage to solve this?