我正在运行6.5.8 Enterprise,并一直在努力解决这个问题。
我需要与广告系列和产品模板建立多对多关系。然而,工作室似乎只能管理一对一。我似乎没有关系,但似乎无法让子面板工作。
我做了以下事情:
1:在custom / extension.application / ext / tabledictionary / campaigns_producttemplates.php中添加引用:
include('custom/metadata/campaigns_producttemplatesMetaData.php');
2:将以下内容放在上面引用的文件中:
<?php// created: 2015-04-10 14:19:05
$dictionary["campaigns_producttemplates"] = array ( //The table name
//'true_relationship_type' => 'many-to-many', //Relationship type
'relationships' =>
array (
'campaigns_producttemplates' => //table name
array (
'lhs_module' => 'Campaigns', //Module name as per directory
'lhs_table' => 'campaigns', //Table Name
'lhs_key' => 'id', //should be id
'rhs_module' => 'ProductTemplates', //Module name as per directory
'rhs_table' => 'product_templates', //Table Name
'rhs_key' => 'id', //should be id
'relationship_type' => 'many-to-many', //Relationship type
'join_table' => 'campaigns_producttemplates',//Table name
'join_key_lhs' => 'campaign_id', //ID reference of the left side module
'join_key_rhs' => 'product_template_id', //ID reference of the right side module
),
),
'table' => 'campaigns_producttemplates', //table name
'fields' =>
array (
0 =>
array (
'name' => 'id', //ID is needed as a unique id
'type' => 'varchar',
'len' => 36,
),
1 =>
array (
'name' => 'date_modified', //Required
'type' => 'datetime',
),
2 =>
array (
'name' => 'deleted', //Required
'type' => 'bool',
'len' => '1',
'default' => '0',
'required' => true,
),
3 =>
array (
'name' => 'campaign_id', //Referenced as the above left key
'type' => 'varchar',
'len' => 36,
),
4 =>
array (
'name' => 'product_template_id', //Referenced as the above right key
'type' => 'varchar',
'len' => 36,
),
),
'indices' =>
array (
0 =>
array (
'name' => 'campaigns_producttemplatesspk', //Index for the primary key
'type' => 'primary',
'fields' =>
array (
0 => 'id',
),
),
1 =>
array (
'name' => 'campaigns_producttemplates_alt', //Index for the foreign keys
'type' => 'alternate_key',
'fields' =>
array (
0 => 'campaign_id', //Change this to the left side key
1 => 'product_template_id', //Change this to the right side key
),
),
),
);
3:将以下内容放入custom / extension / modules / campaigns / ProductTemplatesRelate.php
$dictionary['Campaign']['relationships']['producttemplates'] = array(
'name' => 'producttemplates',
'type' => 'link', //Keep as this
'relationship' => 'campaigns_producttemplates', //Many to Many relationship table
'module' => 'ProductTemplates',
'bean_name' => 'ProductTemplates',
'source' => 'non-db', //Leave as is
'vname' => 'LBL_PRODUCTTEMPLATES',
);
4:将以下内容放入custom / extension / modules / campaigns / ext / layoutdefs / product_templates_subpanel.php
<?php
$layout_defs['Campaigns']['subpanel_setup']['producttemplates'] = array(
'order' => 100,
'module' => 'ProductTemplates', //I believe this is the name of Subpanel Module's directory
'get_subpanel_data' => 'product_templates',
'sort_order' => 'asc',
'sort_by' => 'name',
'subpanel_name' => 'default',
'title_key' => 'LBL_PRODUCTTEMPLATES',
'top_buttons' => array (
0 => array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
),
);
5:将以下内容保存在custom / modules / ProductTemplates / metadata / subpanels / default.php
中<?php// created: 2013-11-07 08:42:31
$subpanel_layout['list_fields'] = array (
'name' =>
array (
'type' => 'name',
'link' => true,
'vname' => 'LBL_NAME',
'width' => '10%',
'default' => true,
'widget_class' => 'SubPanelDetailViewLink',
'target_module' => NULL,
'target_record_key' => NULL,
),
);
我通过反复试验得到了这一点,并尝试将其他帖子和帮助文章拼凑在一起,但无法进一步了解。
我可以确认以下内容:
关系显示在工作室
子面板显示Studio
我的campaigns_producttemplates表存在于数据库
数据库
我能看到的唯一日志条目是:
05/05/15 12:54:30 [1604] [1] [致命]坏子面板定义,它有 get_subpanel_data属性producttemplates
的值不正确
非常感谢任何帮助!
答案 0 :(得分:3)
经过大量的搜索和测试,我发现了我的问题:
第3项:
<?php
$dictionary['Campaign']['fields']['campaigns_producttemplates'] = array(
'name' => 'campaigns_producttemplates',
'type' => 'link', //Keep as this
'relationship' => 'campaigns_producttemplates', //Many to Many relationship table
//'module' => 'ProductTemplates',
//'bean_name' => 'ProductTemplate',
'source' => 'non-db', //Leave as is
'vname' => 'LBL_CAMPAIGN_PRODUCT_TEMPLATES_FROM_CAMPAIGNS_TITLE',
);
这需要是“领域”,而不是“关系”。
而且4:
<?php
$layout_defs['Campaigns']['subpanel_setup']['campaigns_producttemplates'] = array(
'order' => 100,
'module' => 'ProductTemplates', //I believe this is the name of Subpanel Module's directory
'get_subpanel_data' => 'campaigns_producttemplates',
'sort_order' => 'asc',
'sort_by' => 'id',
'subpanel_name' => 'default',
'title_key' => 'LBL_PRODUCTTEMPLATES',
'top_buttons' => array (
0 => array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
),
);
我需要确保使用自定义关系来获取子面板的数据。
现在全部工作。