You can only relate built in modules specified in a list (a dropdown list actually) but custom module is not in that list.
This is a hack that allows you to relate to custom modules
This code below is based on release 5.0.0e but I am sure that by pasting the lines in the correct location for any of the release 5 version that you will be able to get this to work. It is a bit ugly, by ugly I mean adding a non language line in the language files. But my goal was the fastest cheapest way to the goal.
Change the file modules/ModuleBuilder/MB/MBLanguage.php the function save
Code:function save($key_name, $duplicate=false){ global $mod_strings; $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); $required = array( 'LBL_LIST_FORM_TITLE'=>$this->label . " " . $mod_strings['LBL_LIST'], 'LBL_MODULE_NAME'=>$this->label, 'LBL_MODULE_TITLE'=>$this->label, //FOR GENERIC MENU 'LNK_NEW_RECORD'=>$mod_strings['LBL_CREATE'] ." ". $this->label, 'LNK_LIST'=>$this->label, 'LBL_SEARCH_FORM_TITLE'=>$mod_strings['LBL_SEARCH'] ." ". $this->label, 'LBL_HISTORY_SUBPANEL_TITLE'=>$mod_strings['LBL_HISTORY'], 'LBL_ACTIVITIES_SUBPANEL_TITLE'=>$mod_strings['LBL_ACTIVITIES'], 'LBL_'.strtoupper($this->key_name).'_SUBPANEL_TITLE'=>$this->label, 'LBL_NEW_FORM_TITLE' => $mod_strings['LBL_NEW'] ." ". $this->label, ); $save_path = $this->path . '/language'; mkdir_recursive($save_path); foreach($this->strings as $lang=>$values){ foreach($required as $k=>$v){ $values[$k] = $v; } write_array_to_file('mod_strings', $values, $save_path .'/'.$lang,'w', $header); } $app_save_path = $this->path . '/../../language/application'; mkdir_recursive($app_save_path); $key_changed = ($this->key_name != $key_name); foreach($this->appListStrings as $lang=>$values){ if(!$duplicate){ unset($values['moduleList'][$this->key_name]); } $values['moduleList'][$key_name]= $this->label; $appFile = $header. "\n"; foreach($values as $key=>$array){ if($key == 'moduleList'){ foreach($array as $k=>$v){ $appFile .= '$app_list_strings["moduleList"]["'. $k .'"] = ' . var_export_helper($v) . ";\n"; } }else{ if($duplicate){ //keep the original when duplicating $appFile .= '$app_list_strings["'. $key .'"] = ' . var_export_helper($array) . ";\n"; } $okey = $key; if($key_changed)$key = str_replace($this->key_name, $key_name, $key); if($key_changed)$key = str_replace(strtolower($this->key_name), strtolower($key_name), $key); // if we aren't duplicating or the key has changed let's add it if(!$duplicate || $okey != $key){ $appFile .= '$app_list_strings["'. $key .'"] = ' . var_export_helper($array) . ";\n"; } } } $fp = fopen($app_save_path . '/'. $lang, 'w'); fwrite($fp, $appFile); fclose($fp); } }
to this
Code:function save($key_name, $duplicate=false){ global $mod_strings; $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); $required = array( 'LBL_LIST_FORM_TITLE'=>$this->label . " " . $mod_strings['LBL_LIST'], 'LBL_MODULE_NAME'=>$this->label, 'LBL_MODULE_TITLE'=>$this->label, //FOR GENERIC MENU 'LNK_NEW_RECORD'=>$mod_strings['LBL_CREATE'] ." ". $this->label, 'LNK_LIST'=>$this->label, 'LBL_SEARCH_FORM_TITLE'=>$mod_strings['LBL_SEARCH'] ." ". $this->label, 'LBL_HISTORY_SUBPANEL_TITLE'=>$mod_strings['LBL_HISTORY'], 'LBL_ACTIVITIES_SUBPANEL_TITLE'=>$mod_strings['LBL_ACTIVITIES'], 'LBL_'.strtoupper($this->key_name).'_SUBPANEL_TITLE'=>$this->label, 'LBL_NEW_FORM_TITLE' => $mod_strings['LBL_NEW'] ." ". $this->label, ); $save_path = $this->path . '/language'; mkdir_recursive($save_path); foreach($this->strings as $lang=>$values){ foreach($required as $k=>$v){ $values[$k] = $v; } write_array_to_file('mod_strings', $values, $save_path .'/'.$lang,'w', $header); } $app_save_path = $this->path . '/../../language/application'; mkdir_recursive($app_save_path); $key_changed = ($this->key_name != $key_name); foreach($this->appListStrings as $lang=>$values){ if(!$duplicate){ unset($values['moduleList'][$this->key_name]); } $values['moduleList'][$key_name]= $this->label; $appFile = $header. "\n"; foreach($values as $key=>$array){ if($key == 'moduleList'){ foreach($array as $k=>$v){ $appFile .= '$app_list_strings["moduleList"]["'. $k .'"] = ' . var_export_helper($v) . ";\n"; } }else{ if($duplicate){ //keep the original when duplicating $appFile .= '$app_list_strings["'. $key .'"] = ' . var_export_helper($array) . ";\n"; } $okey = $key; if($key_changed)$key = str_replace($this->key_name, $key_name, $key); if($key_changed)$key = str_replace(strtolower($this->key_name), strtolower($key_name), $key); // if we aren't duplicating or the key has changed let's add it if(!$duplicate || $okey != $key){ $appFile .= '$app_list_strings["'. $key .'"] = ' . var_export_helper($array) . ";\n"; } } } // Hack by Kenneth Thorman to allow relate to custom modules $appFile .= 'if (!empty($GLOBALS["app_list_strings"]["record_type_display"])) {$GLOBALS["app_list_strings"]["record_type_display"]=array_unique(array_merge($GLOBALS["app_list_strings"]["record_type_display"], array("' . $key_name . '"=>"' . $key_name . '")));}'; // Hack by Kenneth Thorman to allow relate to custom modules $fp = fopen($app_save_path . '/'. $lang, 'w'); fwrite($fp, $appFile); fclose($fp); } }
The lines added are
// Hack by Kenneth Thorman to allow relate to custom modules
$appFile .= 'if (!empty($GLOBALS["app_list_strings"]["record_type_display"])) {$GLOBALS["app_list_strings"]["record_type_display"]=array_unique(array_merge($GLOBALS["app_list_strings"]["record_type_display"], array("' . $key_name . '"=>"' . $key_name . '")));}';
// Hack by Kenneth Thorman to allow relate to custom modules
This works as soon as you create a new module.
You can also relate to self.
Regards
Kenneth Thorman


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks