Hello,
so I'll start with second issue. This is a bug - it's fixed but not released yet.
To fix this on your installation please change little part of code in modules/Utils/RecordBrowser/RecordBrowser_0.php
Replace lines 927-928 with this code:
if (!isset($da['edit'])) {
if ($this->get_access('edit',$row)) $gb_row->add_action($this->create_callback_href(array($this,'navigate'),array('view_entry', 'edit',$row['id'])),__('Edit'), null, 'edit');
else $gb_row->add_action('',__('Edit'),__('You don\'t have permission to edit this record.'),'edit',0,true);
}
This tabbed browser under view mode is called addon. You have to create new recordset and set it as addon to your first recordset. Please have a look at AssetsInstall, there is:
Utils_RecordBrowserCommon::new_addon('company', 'CRM/Assets', 'assets_addon', _M('Assets'));
which means to recordset 'company' put addon with display function 'assets_addon' from module main file 'CRM/Assets' (class CRM_Assets) and translated label 'Assets' (
translation help).
Second parameter has to be module name. You can put here any other class, than module main, because it's created in RecordBrowser as a module.
Now have a look at assets_addon method
public function assets_addon($arg) {
$rb = $this->init_module('Utils/RecordBrowser','crm_assets','crm_assets_addon');
$rb->set_header_properties(array(
'asset_id'=>array('width'=>10),
'category'=>array('width'=>10),
'asset_name'=>array('width'=>15),
'active'=>array('width'=>7),
'general_info'=>array('width'=>70)
));
$rb->set_defaults(array('company'=>$arg['id']));
$this->display_module($rb, array(array('company'=>array($arg['id'])), array('company'=>false, 'active'=>true), array('asset_name'=>'ASC')), 'show_data');
}
As parameters you get your record that is currently in view mode. As second parameter(here not used) you get RecordBrowser module instance.
The most important things here are
set_defaults which sets 'company' field to this from view mode - now when you add new record to assets, company is already chosen. Second thing is parameters to display module. First array is crits and we set crits to display only those asset records which has 'company' field equal to our company id which is currently viewed.
To build your own custom view I suggest to create callback href to method in your module, which will handle all display and other stuff. There is no option to overload default view action in RB.
Firstly create some entrance point to your custom method. For instance, define display callback for some field and return here link to your method.
function display_something($record, $nolink, $desc) {
$val = $record[$desc['id']];
if ($nolink) return $val;
$href = $this->create_callback_href(array('Base_BoxCommon', 'push_module'), array(__CLASS__, 'my_custom_view_mode', array($record)));
return "<a $href>$val</a>";
}
Notice __CLASS__ here. It should work when your display_something is in the module main class (this one in ModuleName_0.php file). Also your my_custom_view_mode has to be there. When you want to mix some modules than use module name in string explicitly.
Now declare my_custom_view_mode method:
function my_custom_view_mode($record) {
// handle and add 'back' button
if ($this->is_back()) Base_BoxCommon::pop_main();
Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
// here do anything you want
}
Best regards,
Adam