简体   繁体   中英

Create a portlet inside of a custom theme in liferay 7

I know in Liferay it is possible to embed a predefined Portlet in a theme's .ftl file by using following code:

<@liferay_portlet["runtime"]
    portletProviderAction=ACTION
    portletProviderClassName="CLASS_NAME"
/>

But I'd like to create a new portlet (with all its Java classes) inside of a theme. For example, a sample skeleton of my theme project can be found in the below.

Liferay 7主题骨架

My question is, In Liferay 7 is it possible to have a complete portlet inside of a theme and end-users access to that portlet? (end-users should be able to add it to wherever they want by using add menu from the right side the admin page).

If yes, where should I place my Java code? How should I deploy and build it? Is there any example of it?

One of the benefits of it is having a theme with many different suitable custom theme in one package and you can share it with others.

I keep myself away from themes these days, but understand that they're largely deployed as webapps, WAR files (which Liferay transforms to WAB bundles internally). While you can have portlets in WAR files, Liferay 7 and DXP work well with many smaller plugins, and you're a lot more flexible by packaging portlets in OSGi bundles.

Unless you implement your portlet in a technology that still requires WAR packaging, you're not gaining a lot from packaging all in the same WAR file. Updating the portlet would cause you to also always having to update the theme and everything else packaged with it - and you can do a lot better with this generation of Liferay.

My advice is to package a portlet as a portlet, and a theme as a theme. The number of plugins doesn't matter any more, as it did in earlier versions. In fact, there are now more than 500 modules (plugins) in the default installation of Liferay DXP. There's no need to minify the number of plugins and no benefit, apart from the number of files you're installing. And that's the last thing I'd worry about.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM