Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a simple custom view in SugarCRM

I am trying to use the MVC architecture of sugarcrm to add a new action and with that a new view.

I have managed to create a controller with the action and also a class view, the only thing I can't figure out is how to create a simple html page.

Do I really have to use the metada way of sugarcrm?? I just want a simple form with two or three fields.

Are there alternatives to the metadata or do I really have to use it to create my simple page????

like image 390
AntonioCS Avatar asked Dec 23 '22 07:12

AntonioCS


2 Answers

You will want to stay within the metadata framework to create your new page if possible. However, once you are in the view controllers, you can echo out anything you wish and still stay "upgrade safe" by overriding the display() function. But, the right way to do what you are wanting to accomplish above is to not only override the display() function but also create a new tpl file (custom/modules//tpls/view.tpl) and then perform whatever you need to perform PHP wise and then assign the variables via the smarty templating engine (I know this sounds complicated - but it's not. It's actually pretty straightforward once you understand Smarty).

One other thing - make sure you are doing all of this (including your controllers and view files) in the custom/modules directory. As this will also keep things upgrade safe. And keep you free from all kinds of headaches in the future. :)

Here is a link to the SugarCRM Developer's Guide online and also a link to their Developer's website. SugarCRM has a pretty good community of developers on the forums so feel free to ask questions there as well.

Developer's Guide: http://developers.sugarcrm.com/docs/OS/5.2/-docs-Developer_Guides-Developer_Guide_5.2-toc.html

Developer's Site: http://developers.sugarcrm.com/

Hope this all helps!

like image 169
swhitlow Avatar answered Dec 28 '22 06:12

swhitlow


Try to do following:

  • create a new module
  • put your page into custom/modules/
  • using URL index.php?module=&action= (without php extension, of course) you can access to your page.

If you'd like to have different action name and page name then you should add the file action_file_map.php into your module directory and specify inside the mapping:

$action_file_map['action_name'] = 'path_to_your_page';

Note that action_name must be all lowercase - the SugarController won't be able to to match mixed-case actions (true as of SugarCRM 6.1.2).

like image 29
michael Avatar answered Dec 28 '22 08:12

michael