Search code examples
javaliferayliferay-7

Liferay 7.1 - Restricted access for porlets/modules to a virtual instances (company)


I created a new virtual instances.

I want to know if I can restrict my custom portlets to be available and to be added in only one virtual instances ?

And, I want to know if Hooks and Fragments can be restricted the same way ? (For exemples, I have a fragment for the user personal bar, and hook for login hook. I want to activate those for only one VI and not for the other).

Thanks,


Solution

  • By deploying your plugins to the server, they're available for everything running on the server, e.g. all virtual instances.

    I believe themes had a declarative way to enumerate the companyId (or companyIds) for which they apply, but other plugins don't have this.

    That being said, with a little bit of more effort, you can still achieve what you'll need: Your plugins most likely have access to the companyId and can do their own checks. You can also customize permissions per virtual instance to remove the "ADD_TO_PAGE" permission for certain portlets for everybody on a virtual instance.

    For Fragments you're probably asking about JSP fragments, as CMS fragments are specific to a site, not even an instance. There you'd have to go with the conditional: If you're on the companyId that you want to change: Render. Otherwise: Skip the modification. However, you should minimize Fragment usage as much as you can: They're quickly developed, but then quickly turn into maintenance monsters: You're dealing with the implementation level of the underlying release and nothing shields you from a change in a later version of the same JSP that you then must 3-way-merge.