How to find a Liferay site id from its "Friendly URL"? - liferay

I am developing a Liferay module. I have a Liferay site's Friendly URL, and I want to get its Site ID (for instance 20143).
GroupLocalServiceUtil has several getGroup methods, but none seem to take a friendly URL as parameter.

GroupLocalServiceUtil has getFriendlyURLGroup method, you can get group, group id is site id.
Group group =GroupLocalServiceUtil.getFriendlyURLGroup(companyId,friendlyURL);

Related

how to access user screen name in liferay url?

I am using Liferay 7.3.2. I have want to redirect the user after login. I have created a public page and define following property in portal-ext.properties file.
default.landing.page.path=/web/${liferay:screenName}/login
How can I access the user screen name in a friendly URL while creating a public page?
I tried as follows but not working: /liferay-screenname/login
I want screen name in the URL because only authenticated users would access the URL.
I am not familiar with these variables in properties, but a possible solution is to do this programmatically and write an OSGi LifecycleAction component for the login.events.post key. In your processLifecycleEvent operation, you can generate a path based on screenName of the logged-in user and set this as session LAST_PATH.
There are some stackoverlow topics about this, that might help here: last-path-redirection-in-custom-login-post-action-in-liferay-7

Liferay 7: Sharing Content

I am new to Liferay and was wondering if the following use case is possible:
Use Case:
Share a piece of content in Site A with Site B.
- No Parent Child relationship between sites
- No Global Content
- The content to be shared is in Site A.
- Site A is set up to share content at the site level.
- Want to add content to a page in Site B, not a site admin or site owner. Regular user. Page is set to be customized.
Have found ways to share some content with placing content in the global space, users having site admin role on both sites, subsites showing parent site content, but nothing that enables our use case to work.
Is this possible to achieve? If so, how?
Not OOTB! The purpose of site is exactly to group (and eventually protect) content and pages. Unless you explicitly share the content (which is what global site is for) it is only available in the site it is defined. There are some other sharing options you've already discovered like parent-child sharing or site admin role sharing but no random sharing between sites.
That said, you can always extend Liferay and do this yourself, taking into account all the security issues and management overhead in introduces. If the content is public (or the user viewing it has the right permissions), you can use IFrame or call the respective jsonws service to get the content and display it.

Setting landing page for different users

I am Using Liferay 6.1CE.
I can able to set my default landing page to a site in control panel.
But in my portal 2 sites are there,two users are there.
For eg: userA is a member of siteA,simularly UserB member of siteB.
How can i redirect the users to their site after login.
What can i do?
I guess 2 sites you mean two communities. Anyway you need to create post login action where you'll check your conditions and redirect where needed.
You can create the Liferay hook for your custom login post action. Please have a look at :
custom action using hook
on how to create the hook.
In the hook, you can identify the looged in user based on your search criteria and redirect to the relevant community.

Add Custom Meta Data to a Team Site Programmatically

I have been asked to write a custom webpage in a web application integrated into a MOSS 2007 solution to allow users to create a teamsite using a custom template. No problem.
However, the user must have the ability to assign custom meta tags to the created team site to allow for specific searches, i.e. to assign country ("USA") and department ("Accounting") tags. Can anyone suggest a way of adding custom properties to the newly created team site via the SharePoint API?
Thanks, MagicAndi
There are 2 options:
You can use the Propertybag (SPWeb.Properties) of the SPWeb object of the new team site
You can add a list (invisble to users except admins) called "site tags" and add some items in there with key value pair fields i.e. item Country with value "USA" etc.

Changing the default page based on security group in SharePoint

We have a SharePoint site collection. In this site collection we have a home site and 6 other sites. Each of these sites belongs to a department in our company. Right now if you are a member of department A security group you would see homepage and your department site/tab when you navigate to the site. What they want me to do is to redirect the users directly to the department site/tab whenever they navigate to the site.
Is there any way to do this without coding or with coding?
With coding, you could write a very simple web control and include that on the home page. It would test which group a user belongs to and then redirect accordingly.
There are various ways to check if a user belongs to a group. One method is to get a reference to each SPGroup object and use SPGroup.ContainsCurrentUser.
You might also like to consider creating a custom list that maps SPGroup name against department URL, so you can manage behaviour of the control through the SharePoint UI.

Resources