How to add custom portlet in Control Panel section

不羁岁月 提交于 2019-11-29 20:55:20

问题


How can I add a custom portlet to the Portal section of the Control Panel, as shown in the following figure:


回答1:


Here is how to do it:

  1. In your portlet's liferay-portlet.xml (you can check the DTD of this xml for more information on other tags) include two tags in your <portlet> tag as shown:

    <portlet>
        <portlet-name>MyCustomPortlet</portlet-name>
        <icon>/mycustom.png</icon>
        <!--
            These are the two entries which are required for the portlet
            to appear in the control panel
        -->
        <!--
            Set the control-panel-entry-category value to "my", "content",
            "portal" or "server" to make this portlet available in the
            Control Panel under that category.
        -->
        <control-panel-entry-category>portal</control-panel-entry-category>
    
        <!--
           Set the control-panel-entry-weight value to a double number
           to control the position of the entry within its Control Panel
           category. Higher values mean that the entry will appear lower
           in the Control Panel menu.
        -->
        <control-panel-entry-weight>100</control-panel-entry-weight>
    
        <instanceable>false</instanceable>
        <header-portlet-css>/css/main.css</header-portlet-css>
        <footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
        <css-class-wrapper>mycustomportlet-portlet</css-class-wrapper>
    </portlet>
    
  2. Also, if you don't want your portlet to appear in the Add Menu so that it is not put on other pages, then in your liferay-display.xml you can include:

    <display>
        <category name="category.hidden">
            <!--
               Adding your portlet to the hidden category would not display
               the portlet in the ADD Menu on the top-left-hand corner
            -->
            <portlet id="MyCustomPortlet"></portlet>
        </category>
    </display>
    
  3. Build and deploy your portlet and you are good to go.




回答2:


Apart from the Answer by Prakash K, ajaxable and instanciable should be false.



来源:https://stackoverflow.com/questions/14066674/how-to-add-custom-portlet-in-control-panel-section

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!