Message Boards

Get list of web content templates

Nikita Laitinen, modified 3 Years ago.

Get list of web content templates

Junior Member Posts: 44 Join Date: 12/18/19 Recent Posts
Hello!

​​​​​​​How to get the names of all web content templates that are used on the web page?
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Get list of web content templates

Liferay Legend Posts: 6396 Join Date: 9/23/08 Recent Posts
Nikita Laitinen:

​​​​​​​How to get the names of all web content templates that are used on the web page?

I guess you mean programmatically?
You'll have to know what you're looking for: E.g. you can analyze the page and check which Web Content Display portlet is on there, retrieve its configuration, check for the article's configured template. You'd need to do that with any other way an article can appear on a page, e.g. through analyzing what AssetPublisher shows (which might be different for any visitor when filtering with user properties). Also, the method will likely differ between Widget- and Content-Pages.
You can start with this ugly but informative portlet: https://github.com/olafk/layout-info-web
Nikita Laitinen, modified 3 Years ago.

RE: Get list of web content templates

Junior Member Posts: 44 Join Date: 12/18/19 Recent Posts
Yes, you're right, I mean programmatically.
I will check that portlet.
​​​​​​​Thanks for the info!
Lee Jordan, modified 2 Years ago.

RE: Get list of web content templates

Expert Posts: 449 Join Date: 5/26/15 Recent Posts

Would be easier with jQuery if each widget title said the template/structure name instead of <span class="portlet-name-text">Web Content Display</span>. You could then for each <section> in jQuery and abstract the name of the templates on the page. All you'd get now is repeated "Web Content Display" as names. Also you could group them, say there were 3 Card Smalls on the page like "Card Small (3)" and of course this could be put into a sidebar or information panel.

It seemed to be done for content pages you can get a tree structure of what's on the page, but hasn't been done for widget pages which is a missed opportunity.