Find Source for Portlet - liferay

To learn more how to implement portlets in Liferay, I want to view the src of existing portlets, e.g. the "Documents and Media" Portlet. Where can I find this src code? I downloaded the src of Liferay but I cant find the relevant files.

The way to learn more about building portlets in Liferay is probably to check out the Liferay Plugins repository, rather than Liferay Portal source.
Some Liferay portlets come OOTB in Liferay Portal itself -- that's what #ArtemKhojoyan is mentioning above. However, as these portlets are pretty thoroughly integrated with the portal itself, they may not be super helpful in figuring out how to make a plugin to deploy on Liferay.
To check out some more standalone portlets, download the Plugins repo -- either by cloning the source on github with https://github.com/liferay/liferay-plugins.git, or downloading a plugins SDK at http://www.liferay.com/downloads/liferay-portal/additional-files -- and open up the portlets/ folder -- that's probably going to be more helpful in showing you hot-deployable portlets that will be more similar to something you'd make yourself.

For Liferay 6.2.0:
Java: \liferay-portal-src-6.2.0-ce-ga1\portal-impl\src
JSP: \liferay-portal-src-6.2.0-ce-ga1\portal-web\docroot\html\portlet
Your required case:
Java: \liferay-portal-src-6.2.0-ce-ga1\portal-impl\src\com\liferay\portlet\documentlibrary
JSP: \liferay-portal-src-6.2.0-ce-ga1\portal-web\docroot\html\portlet\document_library

Related

Liferay Portal customization

I'm new to the Liferay Portal and I have been assigned to develop a Liferay application with the following structure:
logo
search bar
result list
We plan is to sell the application to different customers so the resources like images (logo and so on) and css need to be customizable. According to this tutorial resources like images and style sheets are part of the portal apps which are deployed to Liferay. So in my case for 2 different customers I would need 2 different app versions. Instead I'd like to have one version of the portlet which would load all the resources from a database (maybe via a rest call to an appropriate configuration service). That would give us an opportunity of a better provisioning.
Furthermore I'd like to be able to share css resources between different portlets.
Any ideas how I can achieve this 2 goals?
You seem to be talking about themes. You need to create a Liferay Theme. You can Extend an existing Liferay theme or create a brand new. Themes are like portlets meaning you deploy them the same way only they are specific for what you seem to be descibing. Take a look at https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/theme-builder.
Here you have lots of examples https://github.com/liferay/liferay-plugins/tree/master/themes and scripts for generating new themes.
Hope it helps
As Sudakatux said, you're talking about themes. I'd just like to add a couple of things:
If you're talking about styling portlet content (i.e. what should it look like when you display content in a portlet), you want to search for Application Display Templates (see links below).
If you're talking about styling portlet itself, i.e. what it looks like when you place portlets on your LR, you can do that within a theme.
Themes in Liferay 6.2 and 7.x are incompatible. You tagged the question LR-6 and LR7; I'd recommend choosing one (LR7 is vastly easier and faster to develop themes for, in my experience)
If you are creating your own portlet, and you want to style the content of your own portlet, you'll have to do that within JSPs. Edit: You can also use Freemarker with your portlets; however, I personally still prefer JSPs due to the sheer power of what you can do within it.
Useful links:
Liferay 6.2 Lunar Theme tutorial - shows how to create and deploy LR 6.2 theme
Liferay 7 Theme sample - LR7 has a Blade project that shows a lot by example. You can change Maven to Gradle and vice versa. Very useful.
Application Display Template LR7
Application Display Template LR6
This is how your theme directory structure should be laid out in Liferay 7 DXP. Make sure though you create a Liferay Workspace and create a Liferay module ( theme ) in that workspace. If you do not, you will have lots of errors and cause yourself much confusion.
You can put all your css changes in the _custom.scss file and they will overwrite the default css styles.
Blade CLI will generate the core freemarker templates. I recommend a header/footer template as well.
Lastly, this is how you reference the logo in your freemarker template
<a class="${logo_css_class}" href="${site_default_url}" title="<#liferay.language_format arguments="${site_name}" key="go-to-x" />">
<img alt="${logo_description}" class="logo1" src="${site_logo}" />
</a>

Importing Existing Eclipse Projects into Liferay IDE

I'm trying to convert a Dynamic Web Project in Eclipse into a Liferay Project (ultimately a portlet).
I create my DWP, but I don't see the option to Convert to Liferay project when I right-clilck.
In the Liferay Docs, it states:
Note: If you don't have a convert action available it means either
that the project is already a Liferay IDE project, or that it is not
faceted (i.e., Java and Dynamic Web project facets are not yet
configured). Configure accordingly before moving on.
What do they mean by "Configure accordingly" and how can I accomplish this?

Converting Vignette Portlets to Liferay Portlets

As the title states, i'm trying to convert these Vignette portlets into Liferay portlets.
Is there any documentation on this anywhere? I've searched the entire Internet
-When trying to deploy my WARs right off the bat, I'm getting a "missing liferay.plugin.packet.xml" which tells me the entire portlet must be reconfigured to work with Liferay.
-Running Liferay 6.1.1 ga2 on Web Logic 12c server
Cheers!
You mean "liferay-plugin-package.xml", don't you?
You will find such a file in the source of Liferay at /portal-web/docroot/WEB-INF/liferay-plugin-package.xml. For other examples just download sources from other Portlets (Github or Liferay-Marketplace).
Besides some other values, this file defines how Liferay should handle your war (layout-template, portlet, theme).
EDIT: As the marketplace does not allow (plz see the comment in: liferay-plugin-package_6_1_0.dtd) portlets having an liferay-plugin-package.xml, I would recommend to use the corresponding properties file.
Reference file (in the portal sources): /definitions/liferay-plugin-package_6_1_0.properties

search documents in liferay

I am a beginner with life-ray and I am facing a simple task,which I don't have the slightest idea of how to deal with:
I want to build a portlet which uses the API to add files to liferay. These files should appear in the global search portlet.
Please, tell me where to start I've read several tutorials like http://www.liferay.com/community/wiki/-/wiki/Main/Adding+search+capabilities+to+a+portlet and http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/-asset-framewo-4
,but I feel that these tutorials skip some important steps.
You need not to build the custom portlet for adding files in liferay. They have provide in build portlet for it. you can just add Document and Media Portlet.
http://www.liferay.com/community/wiki/-/wiki/Main/Document+Library+Portlet

Two portlets with same database

I am developing Liferay portal and I have one portlet which handles the administrator side of the portal and one the client side. The thing is that the clients cannot see the administrator page (including the portlet). Also I have created custom DataBase for the portal (I included my own tables in the Liferay database using Service Builder). Now I want to use the same database so I can take info from it using the client portlet.
Any ideas?
I am using Liferay 6.1 with Tomcat and Liferay SDK plugin for Eclipse.
You can copy the [portlet name]-service.jar from Web-Inf/lib, and paste it to any other portlet's lib folder. Even better if you can do this with maven and add this jar as a dependency. This way you can have access to the Util Classes that your service provides, to any other Portlet
All portlets in a plugin project share the service builder service made by that plugin (because they end up in one war file and thus share runtime context). So you could just put both your portlets in the same plugin and they can both access that plugin's service builder services/tables. I think you will find this is a commonly used approach. The permission and visibility issues you mention are not impacted by this organization.
Doing it this way keeps the deployment simple -- just deploy the plugin's war, done.
If there are reasons beyond your control that require the portlets to be in separate plugins, then it becomes harder -- yannicuLar's approach is one way.
If you have two portlets sharing same tables/entities , you can copy the service.jar to
tomcat-7.0.27\lib\ext a common location where these two portlets can access this .jar at runtime.

Resources