Google Maps: How should I attempt to package the custom controllers and views?
I've got some Google Maps code that I've been working on, that I would like to release on SugarForge, but I'm not sure how to package it. I'm hoping someone can help point me in the right direction.
The Google Maps code is a bit different as it works with existing modules. The Google Maps code is attached to this post. It works with the Contacts, Accounts and Leads modules. It uses custom controllers and views. Concerning the controllers, I can't assume that this will be the "only" custom controller per module. Should I consider rewriting this into custom dashlets instead of action/views?
Here's my current install notes (leads example):
Code:
GOOGLE MAPS INSTALL NOTES:
Most files are located in the custom/modules/Leads dir.
IN STUDIO:
Got to Leads - Fields
Create two new custom fields:
Data Type: Decimal
Name: maps_lat (will generate field maps_lat_c)
Display Label: Latitude
Max Size: 10
Precision: 6
- Will generate float 10,6
Data Type: Decimal
Name: maps_lng (will generate field maps_lng_c)
Display Label: Longitude
Max Size: 10
Precision: 6
- Will generate float 10,6
COPY:
custom/modules/Leads/controller.php
- This file contains the map actions necessary; xml generation, etc.
COPY:
custom/modules/Leads/LeadMapsLogicHook.php
- This file contains the logic hook to remove the geocode information any time an lead is saved/modified.
- This ensures the longitude (maps_lng_c) and latitude (maps_lat_c) values are re-geocoded properly.
ADD LOGIC HOOK:
Add the following into the logic_hooks.php file (note 1 - change to your array def).
custom/modules/Leads/logic_hooks.php
$hook_array['after_save'][] = Array(1, 'removeGeocodeInfo', 'custom/modules/Leads/LeadMapsLogicHook.php', 'LeadMapsLogicHook', 'removeGeocodeInfo');
or create new file, such as:
<?php
// custom/modules/Leads/logic_hooks.php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(1, 'removeGeocodeInfo', 'custom/modules/Leads/LeadMapsLogicHook.php', 'LeadMapsLogicHook', 'removeGeocodeInfo');
?>
COPY:
custom/modules/Leads/views/view.map_display.php
COPY:
custom/modules/Leads/views/view.map_markers.config.php
COPY:
custom/modules/Leads/views/view.map_markers.php
MENU AND LANGUAGE CHANGES
See the following doc:
http://developers.sugarcrm.com/docs/...4.html#9002195
custom/Extension/module/Leads/Ext/Menus/
COPY MENU CHANGES:
custom/Extension/modules/Leads/Ext/Menus/maps_menu.php
<?php
if (ACLController::checkAccess('Leads', 'view', true)) {
$module_menu[]=Array("index.php?module=Leads&action=geocode_adddress", $mod_strings['LBL_LABEL_FOR_MAP_DISPLAY'], "Leads");
}
?>
ADD LANGUAGE:
custom/Extension/modules/Leads/Ext/Language/en_us.maps.php
<?php
$mod_strings['LBL_LABEL_FOR_MAP_DISPLAY'] = 'Display Map';
?>
COPY IMAGES FOR MAPS: (15 .png files)
themes/default/ext/resources/images/map_icons/
Re: Google Maps: How should I attempt to package the custom controllers and views?
Quote:
I can't assume that this will be the "only" custom controller per module
That is a very good comment and something that I would like to call "Grey". It's not core hacking per se, but it's not set-and-forget either. Please try to rewrite your customizations so that they fit in the view files. If you really cannot, there is no choice but to overwrite and hope for the best.
__________________ Developers go here Businesses go there (Dutch)
Re: Google Maps: How should I attempt to package the custom controllers and views?
SugarDev,
Are you saying I should write the Controller Action logic into the views? That seems very anti-MVC, yet I've done that before. I assume the action to file mapping doesn't get overridden and can get included from the Extensions directory?
Here's the Project on SugarForge for those looking for the files:
Re: Google Maps: How should I attempt to package the custom controllers and views?
jjwdesign, I am new to sugar and I'm trying to install your module. Could you point me in the right direction once I copy all the files and create the fields in the studio? Sorry if this is a really newbie question.