Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Default Display Templates(Table, Title Lists, Abstracts) on Liferay 7.2 CE
Hellow, I want to see the code of the Default Display Templates (Table, Title Lists, Abstracts, Full Content ) on Liferay 7.2 CE , can you please let me know where i can see them , I went to Global and click widget templates , there I can see some under Structure.
sree p:
You'll probably need to reindex.
Hellow, I want to see the code of the Default Display Templates (Table, Title Lists, Abstracts, Full Content ) on Liferay 7.2 CE , can you please let me know where i can see them , I went to Global and click widget templates , there I can see some under Structure.
when I reindex i did not see Table, Title Lists, Abstracts ADTs
Some of the ADT (or Widget) templates that are bundled with the portal are actually bundled with the portlets themselves. When a bundled template is added to the system it is visible for configuration, but you can't "edit" them. I think what you might be looking for is in the Liferay source code. I am not sure how true this is for 7.2 in honesty, but this was the case for past versions.
For example, if you wanted to see the templates bundled with the Asset Publisher, in the portal source, you would have a look at the location: /liferay-ce-portal-src-7.2.0-ga1/modules/apps/asset/asset-publisher-web/src/main/resources/com/liferay/asset/publisher/web/portlet/template/dependencies/portlet-display-templates.xml
For example, if you wanted to see the templates bundled with the Asset Publisher, in the portal source, you would have a look at the location: /liferay-ce-portal-src-7.2.0-ga1/modules/apps/asset/asset-publisher-web/src/main/resources/com/liferay/asset/publisher/web/portlet/template/dependencies/portlet-display-templates.xml
Hello, Andrew, where can i see that path folder/Portal source and how can I get into this location: /liferay-ce-portal-src-7.2.0-ga1/modules/apps/asset/asset-publisher-web/src/main/resources/com/liferay/asset/publisher/web/portlet/template/dependencies/portlet-display-templates.xml?
You need to download the archive, unpack it and then go to that path. You can find the src archive for all the current and past versions here -- https://sourceforge.net/projects/lportal/files/Liferay%20Portal/ -- just make sure you pick the file with the "src" in the name. You could also go to github and navigate there, or clone the repo, etc. If you are working with DXP then the source for the version you are running is available on the customer portal.
I did not see the source from 7.2 ce bundle, can you please let me know
It's not in the bundle -- it's a separate download: https://sourceforge.net/projects/lportal/files/Liferay%20Portal/7.2.0%20GA1/liferay-ce-portal-src-7.2.0-ga1-20190531153709761.zip/download
Hi Andrew , I can see the source but could not see the code of FTL for table, Title Lists , Abstracts Display templates
Are you working with a specific portlet? Maybe you can tell me what it is exactly you are trying to do -- that might make this go a little faster.
no, I am working with Display template
Hi Sree,
Sorry, but I'm still no understanding what you are looking for. Templating in Liferay has several contexts. You have Pade Display Templates, Widget (formerly Application) Display Templates, you had WCM Templates, etc. Can you maybe give me the steps to reproduce what you are looking for so that I can get on the same page -- and then possible help?
Sorry, but I'm still no understanding what you are looking for. Templating in Liferay has several contexts. You have Pade Display Templates, Widget (formerly Application) Display Templates, you had WCM Templates, etc. Can you maybe give me the steps to reproduce what you are looking for so that I can get on the same page -- and then possible help?
I want to see the FTL code from ADT of Table, Title Lists and Abstracts Display templates, those default I see on Asset Publisher settings, so just want to look up it's code
sree p:
I want to see the FTL code from ADT of Table, Title Lists and Abstracts Display templates, those default I see on Asset Publisher settings, so just want to look up it's code
There's no FTL for exactly the ones that you'd like to see. They're built-in to Liferay (probably for historical reasons, before Widget Display Templates came up) and you can find their jsps in the source tree in /modules/apps/asset/asset-publisher-web/src/main/resources/META-INF/resources
Yep -- there they are. Mysteriously named --
Digging through the source, in the /configuration/ subdirectory you will find the display_settings.jsp. Here you will find this:
and if we look at the AssetPublisherDisplayContext.getDisplayStyles(), the mystery of how they get into the list is solved.
... so looks like you can control this list from the Control Panel > Configuration > System Settings > Assets > Asset Publisher (widget scope). I guess this means you can add your own with aJSP hook and then configure the name of the file in the config settings. Very cool. Thanks for the helping hand Olaf!
- view_asset_entries_table.jsp
- view_asset_entries_title_list.jsp
- view_asset_entries_list.jsp
- etc.
Digging through the source, in the /configuration/ subdirectory you will find the display_settings.jsp. Here you will find this:
<div class="display-template">
<liferay-ddm:template-selector className="<%= AssetEntry.class.getName() %>" defaultDisplayStyle="<%= assetPublisherDisplayContext.getDefaultDisplayStyle() %>" displayStyle="<%= assetPublisherDisplayContext.getDisplayStyle() %>" displayStyleGroupId="<%= assetPublisherDisplayContext.getDisplayStyleGroupId() %>" displayStyles="<%= Arrays.asList(assetPublisherDisplayContext.getDisplayStyles()) %>" label="display-template" refreshURL="<%= configurationRenderURL.toString() %>" />
</div>and if we look at the AssetPublisherDisplayContext.getDisplayStyles(), the mystery of how they get into the list is solved.
public String getDisplayStyle() {
if (_displayStyle != null) {
return _displayStyle;
}
_displayStyle = GetterUtil.getString(
_portletPreferences.getValue(
"displayStyle",
_assetPublisherPortletInstanceConfiguration.
defaultDisplayStyle()));
return _displayStyle;
}
... so looks like you can control this list from the Control Panel > Configuration > System Settings > Assets > Asset Publisher (widget scope). I guess this means you can add your own with aJSP hook and then configure the name of the file in the config settings. Very cool. Thanks for the helping hand Olaf!
Andrew Jardine:
Yeah - but why would you go through the trouble doing so, when you could just create a new FTL template?
... so looks like you can control this list from the Control Panel > Configuration > System Settings > Assets > Asset Publisher (widget scope). I guess this means you can add your own with aJSP hook and then configure the name of the file in the config settings. Very cool.
My guess would be that this special handling will disappear sooner or later, for a uniform handling of the display styles. And then you'd have to edit FTL again, plus you'd have to migrate the stuff that took longer to implement in the first place. And you'd have to maintain it on every minor update already.
Fair enough. But then ... WHY AREN'T THEY ADTs ALREADY?!
I have taken "the alternate" approach a few times in the past though when I had to build something ALMOST the same with just a few tweaks. Some of those JSPs would be difficult-to-complicated to turn into ADTs -- and you might not have access to some of the classes you need maybe? Like the AssetPublisherDisplayContext?
I have taken "the alternate" approach a few times in the past though when I had to build something ALMOST the same with just a few tweaks. Some of those JSPs would be difficult-to-complicated to turn into ADTs -- and you might not have access to some of the classes you need maybe? Like the AssetPublisherDisplayContext?