Liferay, include one web content in another web content - dialog

Let's say I have web content, which is a modal dialog. Now I want to be able to reuse this content in several other web contents. What is the easiest way to achieve this without copy modal code to each web content? JavaScript is allowed.

Web content is a modal dialog? I don't understand the usecase, thus it's hard to give proper sample code.
If you're aware of the ID of the other webcontent that you want to use, you can retrieve this content through the API, e.g. by writing structures/templates. Templates are able to access the API and render other articles. Some of the API is hidden from templates by default, but you can revert this - look for "restricted" in portal.properties
The WCM API is named after its formal name "Journal*", check the API, e.g. JournalArticleService.

Related

Display Document Library from Hub Site

Other than using the "embed" webpart, is there a way to display a document library from a Hub site on an associated site?
Or a way to change the look of the embedded library so that the header commands are not visible or the view defaults to its own view?
I want to get rid of the "new", "upload", "edit" headers but still allow filtering.
There is no option to display a document library from a hub site on an associated site except for the Embed web part.
If you only need to display files from an associated site, you could consider to use the "Highlighted Content" web part on a modern page.
It allows you to pick up contents, then filter by content type, file type, and managed properties. You can use the "path" managed property to only get documents from a specific library (Path Begins with {library url}).

Azure AD B2C Password reset flow custom layout password validation not working properly

I've created a custom layout for the "Password reset" user flow.
The password entry validation does not work properly, it does not always detect entries and when it does the information it provides is incorrect.
My layout has no custom CSS or JavaScript, it is just a plain HTML document with the div containing the value api in the id attribute inside the body.
I worked around this issue. I extracted CSS from the default layout provided by Microsoft.
One or some of those CSS classes did the trick, although I am not sure which of those is necessary. I wasn't able to find any information on the custom layout documentation page and that's the actual issue I have.
Generally to avoid this issue, we recommend starting with the templates, and adding your customisation on top. The templates contain a lot of the JS/CSS to control the default controls and error messaging that is part of the page.
https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-ui-customization#customize-the-default-azure-ad-b2c-pages

Liferay static url for dynamic data

I want to serve some data from an static url in Liferay. For example, say to serve a json containing the logged user from "http://server.com/whatever/user" so all the portlets in the proyect can read it. Right now I can do it with a portlet, but then I have to set the url with the configuration panel and I don't like that.
I've seen that I can put jsp files with the static content, but don't know how to access the information of session, users, etc.
Friendly urls seem to accomplish something similar but seem overly complicated and focused in getting a short easy url, something I don't care.
So, how can I get some internal data in an static url (I don't mind if it's friendly, long or short, but always the same) so every element of a Liferay proyect can read it?
FOURTH EDIT: Another way to put it...
In my eclipse I have this tree:
/whatever-war/docroot/html/fancy-porlet/list.jsp
How do I access that jsp in a browser without having to go the Liferay panel and putting the portlet in the menus of the web?
FIFTH EDIT: I haven't had the time to research any more, but I have this in my notes...
https://server/language/c/portal/layout?p_l_id=plid
This goes straight to the portlet, sometimes. plid comes from
PortalUtil.getPlidFromPortletId(themeDisplay.getScopeGroupId(), name_of_portlet_and_war)
It's no solution for me because, it doesn't always work. Sometimes you get a numeric identifier, sometimes you get a zero. I'd bet on the name of portlet and war being incorrect so it doesn't find the portlet, but then, how do you find the new name of the portlet? Sadly, I discarded the code where the name came from, but is coming from Liferay.
SIXTH EDIT: What I want to do is to be able to call a fixed url, with some data internal to Liferay, and get information based on that data back.
There are several aspects here:
Every portlet already has access to the user through a request attribute called ThemeDisplay:
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
Check ThemeDisplay's interface for the various options that you have in order to get the current user's id or object.
You've asked about JSON delivery - this will need to go through Liferay and not (directly) through a JSP in your individual web application. The reason is that any request processed by Liferay will contain the user's information, but as any proper webapp, it's completely separate from any request directed at another webapp: Unless included by Liferay, your JSP will have a different session that has nothing to do with Liferay's session. (I hope this explanation makes sense)
If you write a servletFilter hook, you might not yet have the portal context initialized (Liferay 6.x has been a while for me, pardon for being vague here). If you're on the portlet side, you might have to do more than you expected.
One option that you have is to embed a portlet on every page, automatically (e.g. when it's deployed, it's available). You can configure a portlet to be automatically included on every page, it's done for the chat portlet, for example. That portlet does not need to have any UI, it just needs to expose its resourceURL, so that you can use it from everywhere.
However, I somehow doubt that you use it, given that every portlet has the information already at hand.
But I might also just not understand all of your requirements...

How to link to another liferay page

I'm trying to figure out how to link to another page within the same liferay site.
Obviously I could hardcode the url in my portlet's view but I'm worried about having to update all of my portlets in case the friendly url changes in the future.
I know the name of the page I'm trying to link to, but what if the page name changes too?
I've found infinity of classes that have methods that return friendlyUrls, such as PortalUtil, LayoutLocalServiceUtil, and even LayoutFriendlyURLLocalServiceUtil, but they all require parameters that I'm not sure how to obtain.
Is there a standard way of obtaining friendly urls in liferay?
If you want to link to another Page, you can either use LayoutId or friendly url names.
Both are unique for each companyId, so you are going to be pretty safe using them.
You can set the friendlyUrl as a PortletConfig parameters, so you can set them on portlet Level, and you won't have them hard-coded in your Portlet. Alternatively, you can also save them as custom params in portal-ext.properties (will apply for all portlets of that portal).
Now, that's a lot of code for this, so if you're dealing with specific problems, like creating Portlet Configuration or Reading portal-ext.properties, or creating renderUrls programatically, you should start new questions

Create a web page in Orchard

I need to create a "custom" web page in Orchard. As I understand it, below are the steps I need to take to do so. Before I go down this somewhat lengthy process, are there any steps I'm missing or that I can skip?
Create a model
Create a content part and content part record which use the above model
Create a driver which implements the Display method which returns the "shape" of the content part
Create a shape template to render the shape returned from the above driver
Create a content type which holds the content part
Create a page which holds the content type
Add the page to my site
This page is "custom", in the sense that it needs to pull data from a web service and display it in an interactive way. When the user makes changes, those changes will need to be sent back to the web service.
Those are really steps for creating a content item. You would want to create a content item if your page should be treated as content - e.g. administrators can create, edit, publish, unpublish, and finally delete your page.
If you just want to create a simple page, then there is nothing to stop you from creating your own ASP MVC controller. You can define routes for it using Orchard's routing, and if you decorate it with a [Themed] attribute, it will even inherit the site's theme.

Resources