Creating a simple custom view in SugarCRM

AntonioCS picture AntonioCS · Nov 30, 2009 · Viewed 12.7k times · Source

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????

Answer

swhitlow picture swhitlow · Dec 1, 2009

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!