Module metadata edit|view def not loading includes

custom modules with includes to dynamically load external files e.g. javascript are not loading correctly in SpiceCRM UI.

Souce shows no trace of the specified include file (while original Sugar 6.5.X works correctly).

An example:

'includes' => 
  array (
    0 => 
    array (
          'file' => 'cache/include/javascript/sugar_grp_yui_widgets.js',
    ),
  ),

to resolve this we had to move all includes by extending the EditView and DetailView to echo the javascript prior to display; but its less elegant

Can this be investigated and resolved?

thorsten,

edit file include/Smarty/plugins/function.sugar_include.php and uncomment line 59

function smarty_function_sugar_include($params, &$smarty)
{
    global $app_strings;

    // bugfix proper include js files from metadata
    // (if(empty($params['file'])) return;

    if(isset($params['type']) && $params['type'] == 'php') {
		if(!isset($params['file'])) {
		   $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include');
		} 

let me know if that fixes the issue. If it does we will check it intot he general Repository.

one more addition … just did some testing and when PHP files are included this might lead to errors.

function smarty_function_sugar_include($params, &$smarty)
{
    global $app_strings;

    // bugfix proper include js files from metadata
    // if(empty($params['file'])) return;

    if(isset($params['type']) && $params['type'] == 'php') {
		if(!isset($params['file'])) {

		   //$smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include');
                   return;
		} 
		
		$includeFile = $params['file'];
		if(!file_exists($includeFile)) {
		   // $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile);
                   return;
		}
		
	    ob_start();
	    require($includeFile);
	    $output_html = ob_get_contents();

To Avoid that further comment out the lines $smarty->trigger_error and add return; there as in teh coding above