通过清单文件将面板添加到 editviewdefs.php [英] Adding panels to editviewdefs.php via manifest file

查看:18
本文介绍了通过清单文件将面板添加到 editviewdefs.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

详细视图中的SugarCRM可安装更改问题是关于如何添加面板,使用模块安装程序的清单文件添加到现有模块的编辑视图/详细视图,而不清除之前在自定义目录中进行的自定义.

In SugarCRM installable changes in detailview the question was asked about how to add a panel, using the Module Installer's manifest file to add to the the editview/detailview of an existing module without wiping out customizations previously made in the custom directory.

答案是如何添加字段,而不是面板.

The answer was provided how to add fields, but not panels.

我知道您可以使用从清单文件中调用的 post_execute 函数来编辑/自定义/模块//元数据/目录,但这涉及对这些文件中已经存在的内容进行一些猜测.

I know you could use a post_execute function called from the manifest file to edit the editviewdefs.php and detailviewdefs.php files in the /custom/modules//metadata/ directory, but that involves making some guesses about what already exists in those files.

有谁知道如何通过增量添加面板的清单文件(或 post_execute)添加面板,而不用使用 php 代码手动编辑 editviewdefs.php 和 detailviewdefs.php 文件?

Does anyone know how to add panels via the manifest file (or post_execute) that incrementally adds the panel, without using php code to manually edit the editviewdefs.php and detailviewdefs.php files?

推荐答案

您在使用 ParserFactory 类,它可以从 post_install 或在安装模块/包时执行的类似脚本中使用.我的理解是 ParserFactory 会调用自定义文件(如果它们在那里),或者库存文件,如果没有,则适当且安全地调整它们.

You're after the ParserFactory class, which can be used from a post_install or similar script executed as your module/package is installed. My understanding is that ParserFactory will call custom files if they're there, or stock files and adjust them appropriately and safely if not.

在您的模块目录中,创建一个名为scripts"的子目录并创建post_install.php",其中包含一个函数 post_install().您的包目录将如下所示:

In your module's directory, create a subdirectory called 'scripts' and create 'post_install.php' which contains a single function post_install(). Your package dir will look something like this:

~$ find .
/LICENSE.txt
/manifest.php
/scripts/post_install.php

您可以像这样使用 ParserFactory:

You use the ParserFactory like this:

<?php
function post_install(){

// $parser becomes an associative array for the metadata, similar to editviewdefs.php
require_once('modules/ModuleBuilder/parsers/ParserFactory.php');
$parser = ParserFactory::getParser('detailview', 'Accounts');

// finding the panels (which contain their fields), you can 
// now add fields or additional arrays to this array, creating new panels
// (you could manipulate $parser->_viewdefs directly, but I find this easier)
$panels = array_keys ( $parser->_viewdefs [ 'panels' ] );

// place your panels back into the $parser and save
$parser->_viewdefs['panels'] = $panels;
$parser->handleSave(false);

};

这篇关于通过清单文件将面板添加到 editviewdefs.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆