views:

868

answers:

2

Hey!

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

+2  A: 

Hello - 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%5FGuides-Developer%5FGuide%5F5.2-toc.html

Developer's Site: h t t p : / / developers.sugarcrm.com /

Hope this all helps!

swhitlow
Thanks! I have been doing all this in the custom dir :) I didn't know about the tpl folder. But metadata is a bit complicated and I really hate smarty, smarty's another language and I just want to create a form with some inputs and a select or two, and I think via php I would have much more freedom. The tpl doesn't necessarily have to be a sugar file right?
AntonioCS
A: 

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';
michael