首页 > 解决方案 > 使用 Moqui 创建自定义组件并使用 MoquiConf.xml 挂载

问题描述

我对 moqui 还很陌生,并寻求一些帮助来使用 moqui 创建自定义组件并使用 MoquiConf.xml 将应用程序安装在 webroot 上

我已阅读https://www.moqui.org/MakingAppsWithMoqui-1.0.pdf并创建了教程组件并使用https://www.moqui.org/MakingAppsWithMoqui-1.0.pdf的以下部分成功安装

在 apps.xml 文件的 subscreens 元素下添加一个 subscreens-item 元素,例如:

 location="component://tutorial/screen/tutorial.xml"/>

然而,我的理解基于以下 Moqui 文档的阅读——> https://www.moqui.org/docs/framework/User+Interface/XML+Screen是我应该能够在我的自定义组件目录中使用 MoquiConf.xml -> screen-facade 安装自定义组件,而不必在 webroot 下的 apps.xml 中进行更改(我真的很喜欢这个想法)对于#4(Moqui Conf XML 文件),您可以将这些元素放在合并到该运行时配置中的任何 Moqui Conf XML 文件中。执行此操作的主要方法是在组件目录中的 MoquiConf.xml 文件中,因此配置与屏幕位于同一组件中,您不必在其他地方修改和维护文件。在运行和部署说明中查看有关 Moqui Conf XML 选项的更多详细信息。以下是 moqui/example 组件中 MoquiConf.xml 文件的示例:

<screen-facade>
    <screen location="component://webroot/screen/webroot/apps.xml">
        <subscreens-item name="example" menu-title="Example" menu-index="97" 
            location="component://example/screen/ExampleApp.xml"/>
    </screen>
</screen-facade>

但是我无法让它工作,我在教程组件中尝试了 MoquiConf.xml 方法,还制作了示例组件的副本,但仍然没有乐趣,感谢任何指针

我尝试使用教程项目 component/tutorial/MoquiConf.xml 的配置

<?xml version="1.0" encoding="UTF-8" ?>
<!-- No copyright or license for configuration file, details here are not considered a creative work. -->
<moqui-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/moqui-conf-2.1.xsd">
    <screen-facade>
        <screen location="component://webroot/screen/webroot/apps.xml">
            <subscreens-item name="tutorial" menu-title="Tutorial" menu-index="98" location="component://tutorial/screen/tutorial.xml"/>
        </screen>
    </screen-facade>
</moqui-conf>

组件/教程/屏幕/tutorial.xml

<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-2.1.xsd"
        require-authentication="false" include-child-content="true" menu-image="glyphicon glyphicon-wrench" menu-image-type="icon">
    <subscreens default-item="hello">
    </subscreens>
    <widgets>
        <label type="h1" text="Hello world with Sub Screens!"/>
        <subscreens-panel id="hello-app" type="popup"/>
        <subscreens-active/>
    </widgets>
</screen>

组件/教程/屏幕/教程/hello.xml

<screen>
 <widgets>
     <render-mode>
         <text type="html"
 location="component://tutorial/screen/tutorial/hello.html"/>
     </render-mode>
 </widgets>
</screen>

组件/教程/屏幕/教程/hello.html

<h1>Hello world! (from the hello.html file)</h1>

使用上面的 MoquiConf.xml 配置,教程组件甚至不会显示在 Applications --> AppList (Menu) 中,但是当我使用 base-component/webroot/screen/webroot/apps.xml 中的以下更改加载时可以工作

<subscreens default-item="AppList">
        <subscreens-item name="tutorial" menu-title="Tutorial"
                 location="component://tutorial/screen/tutorial.xml"/>
    </subscreens>

很确定我错过了一个配置,因为上面似乎可以在示例、工具和可能的其他组件中使用,感谢任何指针

标签: componentsconfigscreenmountmoqui

解决方案


抱歉耽搁了,我可以使用 David 评论中包含的在线教程 -> moqui.org/docs/framework/Quick+Tutorial,并成功完成教程,谢谢 David。


推荐阅读