I have seen methods in Hybris returning a JSP or dynamically doing getViewForPage.What is the difference between the two approaches.Is it the static or dynamic difference?What should be used when?Can I add new components with just returning a JSP using return statement?
I would strongly recommend to use the getViewForPage method every time. There are a lot of reasons why. Here are just the 2 most important from my point of view:
For every CMS Page Template you can define the "frontendTemplateName", which is the reference to the JSP view. The advantage here is that it can be maintained in the database. So if you decide to use a different JSP to display a CMS Page Template, all you need is to change the frontend template name and hybris uses a different JSP to render this template. This advantage is gone if you return just the JSP file. It also helps to avoid repetition of the JSP name in your code.
Additionally consider restrictions to pages. hybris is able to display different pages depending on maintained restrictions. It is not possible to use restrictions on CMS Pages when using the JSP name in your code.
As long as you use the "storeCmsPageInModel" method, you can use CMS Components in your template. No matter if you use JSP or getViewForPage. However with the getViewForPage method you make sure, that the right JSP is used and that the configured frontend template name has the right content slots to display your components.
Maybe this question is not intended, but I would strongly recommend to use CMS Pages for every possible purpose. We developers have seen requirements change over time and CMS Pages offer all the flexibility you need to respond to this change.
Related
I need to obtain a property that is set in portal-ext.properties from my theme's portal_normal.ftl file. Using Liferay 7.
All my searches have come up short, but I can't believe I'm the first one to have this need.
For background, I need to display a web content that is stored in the global site. This needs to be displayed on every site, which is why it's going into the theme. It also needs to be updated by the content editors, so the content can't be included in the theme.
I can display the web content easily, using the journalArticleLocalService like this
journalArticleLocalService.fetchArticle(10197,"1260480")
but I obviously don't want to hard code the group ID and article ID like this; and they are already stored in portal-ext.properties for another reason.
Also, I know about theme configuration values, I use them for a lot of other configuration needs, but those require the values to be entered for each site and there are hundreds of sites in our implementation so this is not an option.
Thanks in advance for any solutions or advice you can provide.
Properties are (as far as I know) not available in Liferay's Freemarker Templates - and as everything in Liferay tries to phase them out in favor of OSGi based configuration) I'd not recommend keeping up the configuration there. Any change requires a restart of the portal - proper configuration would make them hot-changeable.
However, as you now have this situation and probably look for a quick solution: You can create a TemplateContextContributor and make the required values available for your template.
I have a huge amount of content that is in pre-generated static html pages. I am working with an organization that runs their web site using Kentico (11) on IIS. They wish to host the pregenerated HTML, but to have a consistent look and feel on the pre-generated pages.
Is there a way to includes tags etc inside the pre-generated html that gets kentico to process the content to give the standard look and feel for the website, without having to convert the content (potentially 100k+ pages) to normal kentico content (it just doesn't seem like a feasible approach, since the content is refreshed from the source regularly)
There is definitely no out of the box way to that. I also agree it is not a great approach overall. However, if someone was very determined to make it work and if you really had to, custom programming could make that happen.
You could create some custom logic and use the Kentico API (maybe in a scheduled task if the content is periodically refreshed). The custom code could possibly build out a content tree that is based on the folder structure of the files (if portal), or build out some routing logic (if mvc) to route requests. Those requests that match the ~/filename.html could then be intercepted by Kentico and your custom code, read the contents of that filename.html from disk, and use it as a datasource type of webpart (if portal engine) or a repository / model (if MVC), then use that info to populate the presentation layer of the response of the final html to the browser. That way you could wrap that pre-generated content in a master page with some level of control of what the header and footer look like (if portal engine) or a shared layout (if MVC).
Again, I don't recommend it. It might be very slow and tedious to attempt as well as have performance and scalability issues.
It could be a cleaner approach to somehow get that content into a SQL database and then use standard programming to deal with it in the Kentico layer / website.
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).
I find that Liferay concepts are quite confusing.
When I add new items, I don't know what is the best to choose:
Use the web content concept with template and structure
Use the dynamic list records
Use a specific model (using service builder).
All of these are really similars and can achieve same goals.
Have you got any clue or advice on what concept to choose when you develop some new features in Liferay?
You should use the components in this way :
Web Content : Web contents provide convenient way to create, update, view, modify, create RSS feeds, customize the content of the web site. It is one of the main component of the Liferay CMS. You should use web content when,
You have static content and want to show to the site.
You have specific structure of the content (like content with an inline image and a document link), then please use web content with the structure and template
You want to use ready to use content portlets ( web content list, web content display, web content search) instead of creating new set of portlets for your own type.
After all this, Liferay provides customization of web contents by allowing user to add new content type, creating rss feeds, structures, templates, ready workflow, content type roles etc.
Dynamic List : Consider dynamic list as a database with display functionality. Here, you can create a custom type of data and provide display functionality. If you have any requirement like user can create his/her own type of list maintain them, then go for it.
Custom Portlet : If your requirement is very case/scenario specific that you cannot achieve using list or web content or any other Liferay portlets (blogs, wiki, knowledge based articles etc) then go for custom portlet, here please remember, that at every liferay upgrade, you need to review the portlet and update the code accordingly in case of any API change or something. For OOB portlets, Liferay takes care of it.
Hope this helps!
It deends on what you want to have and how much control you want to have over your code.
To make simplistic application use web content concept with template
and structure.(need not to know technologies)
-To make some complex applications use dynamic list records
To make extremely complex applications and have full control over the flow use liferay service builder.(need t be a expert java programmer)
Hope that helps :)
I'm using OOTB Table Of Content web part. However, the structure that it displays slightly differs from the one I need to show. I need to hide several node + render some additional. I though that I could take advantage of the control that is used that Table Of Content web part (if there's one). Is it possible to achieve?
Thanks
I think you should use Content Query Web Part or you can create a new web part using OOTB toc web part as a base and render it on your own. You can do additional operations that way as well.