サブパネル内の表示項目数を個別に設定する
出典: SugarForum.jp
Sugar 5.x の場合
バージョン5.0.0現在、サブパネルごとに表示項目数を変更するには、ソースコードに手を加える必要があります。
#SugarRoot/include/ListView/ListView.php function processUnionBeans(...){ /*省略*/ //$response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, -1, $this->query_limit,$subpanel_def); global $sugar_config; $list_max_entries = array_key_exists('list_max_entries',$subpanel_def->_instance_properties) ? $subpanel_def->_instance_properties['list_max_entries'] + 0 : $sugar_config['list_max_entries_per_subpanel'] + 0; $response = SugarBean::get_union_related_list( $sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, $list_max_entries, $list_max_entries, $this->query_limit, $subpanel_def); $this->records_per_page = $list_max_entries; /*省略*/ }
上記のファイルで、「$response = 」のところ(870行付近)をコメントアウトし、上に示すように書き換えます。その上で、subpaneldefsに下記のように list_max_entries プロパティを追加します。
#SugarRoot/modules/@モジュール名/metadata/subpaneldefs.php $layout_defs['SomeModule'] = array( 'subpanel_setup' => array( 'othermodule' => array( 'order' => 80, 'module' => 'OtherModule', 'sort_order' => 'asc', 'sort_by' => 'name', 'list_max_entries' => 30,//サブパネル表示項目数の制御 'subpanel_name' => 'default', 'get_subpanel_data' => 'othermodule', 'title_key' => 'LBL_OTHER_MODULE_SUBPANEL_TITLE', ), ), );
Sugar 6.x の場合
ほとんど5.xのときと同じ。このバージョンから、サブパネルのキャッシュが効くようになっているので、そのあたりのコードを除けつつ。下記、コメントアウトする「$response = 」は905行付近にあるはず。
#SugarRoot/include/ListView/ListView.php function processUnionBeans(...){ /*省略*/
if (!empty($this->response)){
$response =& $this->response;
echo 'cached';
} else {
//$response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1,-1,$this->query_limit,$subpanel_def);
global $sugar_config;
$list_max_entries
= array_key_exists('list_max_entries',$subpanel_def->_instance_properties)
? $subpanel_def->_instance_properties['list_max_entries'] + 0
: $sugar_config['list_max_entries_per_subpanel'] + 0;
$response = SugarBean::get_union_related_list(
$sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset,
$list_max_entries, $list_max_entries,
$this->query_limit, $subpanel_def);
$this->records_per_page = $list_max_entries;
$this->response =& $response;
}
/*省略*/
}
subpaneldefsの書き方は、5.x系を参照して下さい。