What you need to do is add a many-to-many relationship along with the appropriate sub-panel definitions. Here is roughly what you need to do without going into too much detail. This should get you going in the right direction. This can be done in an upgrade-safe way, but unfortunately cannot be done via the Module Builder. Contact us directly if you need additional help.
1. Build and deploy our Channels custom module
2. Add a many-to-many relationship such as:
PHP Code:
$dictionary['accounts_channels'] = array ( 'table' => 'accounts_channels',
'fields' => array
(
array('name' =>'id', 'type' =>'varchar', 'len'=>'36'),
array('name' =>'account_id', 'type' =>'varchar', 'len'=>'36', ),
array('name' =>'channel_id', 'type' =>'varchar', 'len'=>'36', ),
array('name' => 'date_modified','type' => 'datetime'),
array('name' =>'deleted', 'type' =>'bool', 'len'=>'1', 'default'=>'0','required'=>true),
),
'indices' => array
(
array('name' =>'accounts_channels_pk', 'type' =>'primary', 'fields'=>array('id')),
array('name' => 'idx_account_channel', 'type'=>'alternate_key', 'fields'=>array('account_id','channel_id')),
),
'relationships' => array (
'accounts_channels' => array('lhs_module'=> 'Accounts', 'lhs_table'=> 'accounts', 'lhs_key' => 'id',
'rhs_module'=> 'Channels', 'rhs_table'=> 'channels', 'rhs_key' => 'id',
'relationship_type'=>'many-to-many',
'join_table'=> 'accounts_channels', 'join_key_lhs'=>'account_id', 'join_key_rhs'=>'channel_id')
)
)
3. Add the Sub-Panel definitions for Accounts for Channels
PHP Code:
'channels' => array(
'order' => 50,
'sort_order' => 'desc',
'module' => 'Channels',
'subpanel_name' => 'default',
'get_subpanel_data' => 'channels',
'title_key' => 'Channels',
'top_buttons' => array(
array('widget_class' => 'SubPanelTopButtonQuickCreate'),
array('widget_class' => 'SubPanelTopSelectButton')
),
),
4. Add a link field definition to Accounts vardefs.php
PHP Code:
'channels' =>
array (
'name' => 'channels',
'type' => 'link',
'relationship' => 'accounts_channels',
'module'=>'Channels',
'bean_name'=>'Channels',
'source' => 'non-db',
'vname' => 'Channels',
),
Bookmarks