Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
lou cat
customised landing page for login portlet [SOLVED]
July 27, 2012 4:20 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Hello!

I'd need to have a customised landing page for each user logged in my portal (well, not one different for every user, but maybe one different according to the role).
As far as I understood from this wiki:

http://www.liferay.com/community/wiki/-/wiki/Main/Customizing+the+default+page+after+login

I'll probably have to hook DefaultLandingPageAction.java (hoping this is valid for Liferay 6 too).

But before that I'd need to know:

1) why setting these properties in portal-ext.properties doesn't change my landing page after login:
auth.forward.by.last.path=true
default.landing.page.path= "my preferred path"

2) what's the exact difference between the login portlet and the built-in login?
If I change the portal properties related to login, will they both change?
At the moment after I login from the login portlet, I then see the same page and the portlet saying I'm logged in with my username...
If I login with the built-in portlet, it goes in the home page and not to the path I chose emoticon

Any contribute is much appreciated... thanks!!
Jignesh Vachhani
RE: customised landing page for login portlet
July 13, 2012 4:03 AM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 783

Join Date: March 10, 2008

Recent Posts

Hi Lou,

Please see the comment for you query.

1) why setting these properties in portal-ext.properties doesn't change my landing page after login:
auth.forward.by.last.path=true
Comment : if users are forwarded to the last visited path upon successful login. If set to false, users will be forwarded to their default layout page.
default.landing.page.path= "my preferred path"
Comment: This is the page path where users are automatically redirected to after logging in.



2)what's the exact difference between the login portlet and the built-in login?
If I change the portal properties related to login, will they both change? Comment: Both are refering the same code internally so they will both change
At the moment after I login from the login portlet, I then see the same page and the portlet saying I'm logged in with my username...
If I login with the built-in portlet, it goes in the home page and not to the path I chose
Comment : this happens because your login portlet will be at landing page.


And for user wise landing, as suggested by liferay wiki ,you can write your login in DefaultLandingPageAction and can achieve the same functionality.
DarshanKumar N Bhatia
RE: customised landing page for login portlet
July 13, 2012 4:14 AM
Answer

DarshanKumar N Bhatia

Rank: Junior Member

Posts: 85

Join Date: March 2, 2010

Recent Posts

lou cat:
Hello!

I'd need to have a customised landing page for each user logged in my portal (well, not one different for every user, but maybe one different according to the role).
As far as I understood from this wiki:

http://www.liferay.com/community/wiki/-/wiki/Main/Customizing+the+default+page+after+login

I'll probably have to hook DefaultLandingPageAction.java (hoping this is valid for Liferay 6 too).


Yes u are right... U need to create Custom Login Hook :For Hook see : http://learntolead-liferay.blogspot.in/

lou cat:

But before that I'd need to know:

1) why setting these properties in portal-ext.properties doesn't change my landing page after login:
auth.forward.by.last.path=true
default.landing.page.path= "my preferred path"



As per Description from portal.properties files it should change.......
Are u getting any error.... ???


#
# Set this to true if users are forwarded to the last visited path upon
# successful login. If set to false, users will be forwarded to their
# default layout page.
#
auth.forward.by.last.path=true

#
# Set the default landing page path for logged in users relative to the
# server path. This is the page users are automatically redirected to after
# logging in. For example, if you want the default landing page to be
# http://localhost:8080/web/guest/login, set this to /web/guest/login. To
# activate this feature, set auth.forward.by.last.path to true. To customize
# the behavior, see com.liferay.portal.events.DefaultLandingPageAction in
# the "login.events.post" property above.
#
default.landing.page.path=
#default.landing.page.path=/web/guest/login

lou cat:

2) what's the exact difference between the login portlet and the built-in login?
If I change the portal properties related to login, will they both change?
At the moment after I login from the login portlet, I then see the same page and the portlet saying I'm logged in with my username...
If I login with the built-in portlet, it goes in the home page and not to the path I chose emoticon

Any contribute is much appreciated... thanks!!
.

There is only one login portlet in Liferay called "Sign-in" which is available in tool category of Add Application menu.

Well I written my custom Hook to forward user to private/public page after login :

package com.liferay.custom.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.liferay.portal.kernel.events.Action;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.struts.LastPath;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.User;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portal.kernel.util.WebKeys;

public class CustomPublicUserPagePostLoginAction extends Action{
@Override
public void run(HttpServletRequest httpsreq, HttpServletResponse httpsres)
throws ActionException {
/* Make sure auth.forward.by.last.path=true in portal.propertie file */
User user= null;
String username=null;
try {
user = PortalUtil.getUser(httpsreq);
username = user.getScreenName();
} catch (PortalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LastPath publiclastPath = new LastPath(StringPool.BLANK, "/web/"+username+"/home");
/* it gives user public page url :/web/test/home */
HttpSession session = httpsreq.getSession();
session.setAttribute(WebKeys.LAST_PATH, publiclastPath);
}
}

It get called whenever I login in Liferay.

HTH...
lou cat
RE: customised landing page for login portlet
July 13, 2012 4:18 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Thank you Jinesh,

I set auth.forward.by.last.path property to false, but still I don't understand why
default.landing.page.path= "my preferred path" doesn't work.
At least now the login portlet redirects to the landing page, but it's still the normal home page while I set another path emoticon
My path points to a private page but I have access to that page, I thought it should redirect to the normal home page just if the logged in user doesn't have permission to view that page... I do!emoticon
lou cat
RE: customised landing page for login portlet
July 13, 2012 4:24 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

DarshanKumar N Bhatia:


As per Description from portal.properties files it should change.......
Are u getting any error.... ???


no I don't see any error in the log, it just goes to the home page as it was the normal behaviour...

DarshanKumar N Bhatia:


There is only one login portlet in Liferay called "Sign-in" which is available in tool category of Add Application menu.



Yes, it's the one I'm using.

Thank you DarshanKumar!
Jignesh Vachhani
RE: customised landing page for login portlet
July 13, 2012 4:28 AM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 783

Join Date: March 10, 2008

Recent Posts

what you are providing in default.landing.page.path property ?

it should be in proper page URL format like /web/guest/home or web/guest/login and those page should be created.
lou cat
RE: customised landing page for login portlet
July 13, 2012 9:03 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

I've tried with a couple of paths (pointing to existing pages of course!), also with public pages, even creating a /web/guest/login one...
but it always redirects to the usual home page emoticon
Jignesh Vachhani
RE: customised landing page for login portlet
July 15, 2012 10:51 PM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 783

Join Date: March 10, 2008

Recent Posts

Please check what you have defined in your control panel portal settings .
Put your screenshots over here also which properties you are setting up.
lou cat
RE: customised landing page for login portlet
July 16, 2012 1:52 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Hi Jignesh,

The portal settings for default landing page on the Control Panel are empty.
What properties do you want me to take a screenshot of?
The ones I can see from the Control Panel -> Server Administration -> Properties are a bit too many emoticon
Do you mean my portal-ext.properties?

thanks!
Jignesh Vachhani
RE: customised landing page for login portlet
July 16, 2012 2:59 AM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 783

Join Date: March 10, 2008

Recent Posts

Yes give details of portal-ext.properties.
I want to see Which properties you set their ?
lou cat
RE: customised landing page for login portlet
July 16, 2012 3:31 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

# CONFIGURATION OF POSTRESQL DATABASE
# PostgreSQL

jdbc.default.driverClassName=org.postgresql.Driver
jdbc.default.url=jdbc:postgresql://147.114.32.185:5432/LR_6_LF
jdbc.default.username=postgres
jdbc.default.password=coding

# CONNECTION POOL
#jdbc.default.jndi.name=jdbc/LiferayPool

# LIVE USERS
live.users.enabled=true

# DISABLING MY PUBLIC/PRIVATE PAGES FOR EVERY USER
layout.user.private.layouts.enabled=false
layout.user.private.layouts.modifiable=false
layout.user.private.layouts.auto.create=false

layout.user.public.layouts.enabled=false
layout.user.public.layouts.modifiable=false
layout.user.public.layouts.auto.create=false

# SETTINGS FOR THE LOCALE/LANGUAGE
locale.prepend.friendly.url.style=2
locales=en_US
locale.default.request=true

# DISABLING PERSISTENT COOKIES
session.enable.persistent.cookies=false

# DEFAULT LANDING PAGE
auth.forward.by.last.path=false
default.landing.page.path=/web/guest/login
DarshanKumar N Bhatia
RE: customised landing page for login portlet
July 19, 2012 3:30 AM
Answer

DarshanKumar N Bhatia

Rank: Junior Member

Posts: 85

Join Date: March 2, 2010

Recent Posts

Have u tried by Hook ??
lou cat
RE: customised landing page for login portlet
July 19, 2012 5:50 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Well not yet, but I guess I'll have to emoticon
I was hoping to be able to use the built-in behaviour, at least at first.
lou cat
RE: customised landing page for login portlet
July 26, 2012 8:57 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

I've created the hook but it doesn't work and I'm getting crazy emoticon

I got the correct URL for every user according to their role or organization, the problem is that the methods I've tried to set that url as the default landing page don't work.

I was trying to override the default page like this:

session.setAttribute(PropsKeys.DEFAULT_LANDING_PAGE_PATH, myURL);

my portal-ext.properties has:

auth.forward.by.last.path=false
default.landing.page.path=

but I've also tried differently and I've tried to modify lastPath variable too (as I've seen some examples that do that), using auth.forward.by.last.path=true,
but the behaviour gets even weirder 'cause instead of going to the home page as usual, it creates a strange url (baseURL+/en/c) that doesn't exist!

I guess it's just a question of setting the correct property but can someone help me with that?
lou cat
RE: customised landing page for login portlet
July 27, 2012 4:19 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

SOLVED emoticon

Eventually I didn't override DEFAULT_LANDING_PAGE_PATH, but I changed the lastPath using the property: auth.forward.by.last.path=true.
I also had to remove the baseURL from lastPath, it was redirecting to a funny page because of that.
Daniel Aschauer
RE: customised landing page for login portlet
May 23, 2013 8:31 AM
Answer

Daniel Aschauer

Rank: Junior Member

Posts: 39

Join Date: October 22, 2012

Recent Posts

At the moment after I login from the login portlet, I then see the same page and the portlet saying I'm logged in with my username...
If I login with the built-in portlet, it goes in the home page and not to the path I chose
Comment : this happens because your login portlet will be at landing page.


That is exactly my problem. I am using the sign-in portlet, and i want to redirect to the last page.
I have set up auth.forward.by.last.path=true, but this will only bring my back to the same page (the page where i placed the sign-in portlet).

Is there a way to get to the last page that is not the login page?
lou cat
RE: customised landing page for login portlet
May 23, 2013 8:53 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

and what about

default.landing.page.path=

?

how did you set this property?

is it working as expected with the normal sign-in url (not the sign-in portlet)?

My portal uses a different landing page according to the user role/organization, so I guess our requirements are different...