Use of Liferays ADT to customize Web Contents - liferay

I'm using Liferays Application Display Templates to render a set of web contents the way I like (which is working quite fine). Below you find my ADT code to list all news.
<table>
<#list entries as entry>
<#assign published = entry.getPublishDate()>
<#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, entry) />
<tr>
<td>${published?string["dd.MM.yyyy"]}</td>
<td>${entry.getTitle(locale)}</td>
</tr>
</#list>
</table>
Now the question I have is how can I customize the actual web content and not just the list of contents? Once I chose one entry to see the full web content using my rendered link I always get a default view with a default headline and some social network buttons and stuff. Is there a way to customize this view as well?
I'm using Liferay 6.2.
Thanks for your help and regards. Sebastian

The question implies we're dealing with Asset Publisher portlet customization.
Liferay 6.2 supports customization of the asset list either with ADTs (ie. Freemarker or Velocity templates) or custom display styles (ie. JSPs).
While the support for asset list customization is excellent, Liferay 6.2 doesn't support ADTs or display styles for the asset details. The detail is always rendered by full_content.jsp.
If you need more control of the HTML output for asset detail (title, back link etc.), you have to hook the JSP (full_content.jsp). For general info on JSP hooks, see Overriding Web Resources in the Developer's Guide.
Please note that by hooking this JSP, you'll be overriding the detail view for all Asset Publisher instances in your portal. It's always helpful to think twice, whether the hook is necessary and if it's worth it at all.
Regarding the social network buttons and stuff - this can be configured in Asset Publisher configuration (see Display tab).

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>

Liferay: How can I get the pages of the site in a web content?

I have a portal in Liferay 6.2, and need to design the velocity template of a web content that must have a menu listing the pages (linked names) of the site where is present.
My questions are:
Is this possible?
What would be the correct way to do this?
Would it be better to make a portlet instead of a web content for this purpose?
Thanks for the help.
It feels a bit like you are trying to solve many problems in a single template - consider to compose the UI from many different elements (e.g. custom portlets) rather than building the one structure/template that fits all requirements.
That being said, as there's also the chance that your template doesn't do more than just displaying the current navigation: You have two options: The out-of-the-box Navigation portlet is quite configurable, you might be able to utilize that one instead of implementing anything yourself (check the configuration options).
And lastly, if you want to implement for yourself: Get hold of the themeDisplay object. With getLayout() you'll get the current page, while getLayouts() you'll get all pages of the current site and can enumerate them. However, there's one problem: You typically don't have access to the themeDisplay object from a CMS template. But there are several ways to still get to the data (search the Liferay forums for cms template themedisplay). Also, an Application Display Template will be a lot more powerful - and you can also check how the layouts collection is built - just search for usage of ThemeDisplay.setLayouts in Liferay's source code. But with ADT we're diverting from your original question.
Liferay offers a sitemap portlet out-of-the-box which lists pages of a site. You can configure it and define your own application display template (ADT).

Use a web content portlet

I am using web content portlet to develop a portal.
Each page has common theme (which includes header and footer) and we have many portlets placed on each page.
One of the portlet on right side is menu which is common on many pages.
I could have kept it as a part of theme but the menu can be subject to change in future and the end user who will be handling the portal is non-developer.
So if they want to change some data in that menu portlet, they will have to change it on every page which leads to duplication of effort.
Like I said, since end user is a non-developer, I cannot make that portlet part of the theme.
So is there any way where one web content portlet be created once and used on many pages?
You can embed web-content in theme as per link
Here articleId as in above link, you can set in theme-setting, refer to link
I have found a solution right now. If anyone has abetter solution than this..they are most welcome. I would like people to share alternate and better solutions
I am using Liferay 6.2
What I did was added a new web content display portlet which like I said created a new blank web content display portlet.
So my usual method was to add content to this portlet. THis was the method I followed. You can click on Select Web Content button and then select the already created portal from the list and you are done. NO need to create duplicate portlets

Which is the Liferay equivalent of a IBM WebSphere Portal / WCM Menu?

I've developed with WPS and WCM for several years and now I am also learning Liferay. I can't help but compare the features and I understand that in Liferay some things are done differently.
I would like to know the best practices to manage the following simple example:
A simple page with a carrousel with several images and links
Google analytics inserted in the page (Reusable in most pages)
The following is how I'd solve it in IBM WPS:
A HTML component with the Google Analytics code that is called in every page (I can't find how to do this in Liferay)
A content definition of an image and a link.
Create several contents for each image and link.
Create a menu that shows the list of content in the form of a carrousel (I can't find how to do this either in Liferay)
I am aware that Liferay has a list portlet and content that has repeatable items. I know I could use these, however its much more usable if I can have on content for each image/link and one reusable HTML snippet of code.
How should I solve this in liferay in the most efficient way?
Thanks!
You have to use Liferay Web Content portlet for creating the carousel. This is available in Control Panel. For your particular requirememnt you have to create a dynamic web content, which involves using of Velocity language and javascript to iterate over a set of images. Infact if you see Liferay's website, the home page has this kind of stuff.
For Google Analytics there are two ways. Liferay is not just meant for creating one site, it caters creation of multiple sites. Each site has a group of pages. You can create site from Control panel again. In the site settings you have this option to add google analytics id. So with each site can have different google analytics id.
If you want to do it at a global level, we add the google analytics script snippet in the Theme of liferay.
To get a better understanding of all the jargons used in Liferay, you have to atleast go through Liferay's documentation. And while going through it you have unlearn what you have previously learned. Liferay has hell lot of features than Websphere portal.
http://www.liferay.com/documentation/liferay-portal/6.1/user-guide

Liferay : custom Web content Display List Portlet

I'm beginner in Liferay, and I need to customize the portlet webcontent display list.
I added a portlet in my page Home, and I managed to see the recent news that I created.
The news is displayed in a table (title, author and date display).
I want to display the news like this:
- The date of the news (above the title of the news)
- The title of the news (which is a link to the news)
I tried to create a structure, but I do not see commits its work?
Thank you to enlighten me?
PS: sorry for this English !!
Liferay is available in source - did you look at the implementation of the webcontent list portlet? You can either create a jsp hook for that portlet or just reimplement a similar one based on what you find in there...
As you say you'd like to customize Webcontent display list I assume you don't want its default behaviour. Once you know what to change in this portlet, read about jsp hooks, create a hook with the jsp changes you'd like (if it's limited to jsp changes) and deploy it.
Liferay's development documentation should have the information that you need, otherwise continue in the wiki on liferay.com
Edit: Also, you might want to look at AssetPublisher - maybe this provides a few more options for formatting your output.
Generally Liferay web content in journalarticle table. I have referred Liferay 6.0 Version.
Now, for showing liferay custom portlet view, you should use Liferay Portlet Creation and Liferay Service Builder.
Here are two useful article on those -
1> Liferay MVC Portlet
2> Liferay Service Builder
Now make the service for journalarticle table and use those in your portlet.
Some useful fields of journalarticle table for your reference are - title, createDate etc.

Resources