[quote="virshu":1a6q7fu3]I am still not clear how to put JavaScript into <head> section, or how to invoke it in the "onload" manner. I am not familiar with scriptaculous - JQuery is pretty much the only library that I've used in the last 5 years.... So, as a workaround, I put <div> before javascript function that loads the map. It's kinda outdated style, but it works![/quote:1a6q7fu3]
In my previous post you find the description of eval_js() method. That's exactly what you need here. 🙂
[quote="virshu":1a6q7fu3]Anyway, now I need some help to integrate this into CRM page. I imagine it would look nice as another tab, along with Notes, emails, etc. I am somewhat confused between modules/CRM/Contacts/theme/Contact.tpl and data/Base_Theme/templates/default/CRM/Contacts/Contact.tpl - what controls the layout of the screen, and what's the difference between the two.[/quote:1a6q7fu3]
Ok, let me explain it bit by bit.
First of all, you have the file modules/<module>/theme/<name>.tpl (for instance the modules/CRM/Contacts/theme/Contact.tpl). That file is coming with the module to provide a way to separate the view layer (interface) from the controller layer (the logic).
Now, that file is copied, during installation, to data/Base_Theme/templates/default/<module>/<name>.tpl (in this eample data/Base_Theme/templates/default/CRM/Contacts/Contact.tpl). This is done to further separate the view and controller. That way, all the *.tpl file end in one place and they can be modified and copied to create new templates.
When EPESI is asking to use one of the *.tpl files, it's using the one in /data folder. Please remember that at certain times (updates) the contents of files in data/Base_Theme/templates/default/ folder will be overwritten, so if you change the contents of that folder, make sure to back up your changes.
The next thing you should know is what this particular tpl contains. RecordBrowser displays a record in 3 major parts:
- the main part of the record (what you see in the top part of the screen)
- the additional fields in the record (the fields that you see in "tabs" at the bottom part of the screen)
- the addons (again - displayed as tabs, but they display data that is not strictly linked with the record, i.e. the entry in the database)
The difference between the last two parts may be a bit blur at first, but simply put - the fields are what's displayed when adding/editing the records, addons are not displayed at this time.
So now that we have 3 parts we're back to our tpl. The tpl provided by Contacts is used to overwrite the way the main part of the record is displayed (the top part). It's useful if you want to re-position some of the fields, like the "Create new company" checkbox and text field. It's also useful to alter the layout like in Meetings or Contacts with Photo module installed.
Assuming that you don't necessarily want to add the map to the top section of the screen, the tpl is of no interest to you. As you said yourself, you'd see that map displayed in a tab in contacts and I should say that's much easier to achieve.
To do so, simply add another "addon" through your module installation routine:
Utils_RecordBrowserCommon::new_addon('contact', 'Your/Module', 'maps_addon', 'Map');
Arguments are:
- RecordSet that you want to create addon for
- your module main class
- method name
- label to be used on the "Tab"
Your method needs only to accept one parameter - it will be the currently displayed record (associative array). And it's that method that you should place your iframe print in. 🙂
[quote="virshu":1a6q7fu3]Second question is how to hook into Contact save procedure - so that when contact information (namely, address) is saved - I can update coordinates accordingly.[/quote:1a6q7fu3]
For that you will need to use the method
Utils_RecordBrowserCommon::register_processing_callback('contact', array('Your_ModuleCommon', 'process_contacts'));
More details available here:
http://www.epesi.org/index.php?title=Ut ... riggers.29
Hope this helps,
Arek