For basics about hooks refer to:
http://www.liferay.com/web/jonas.yuan/blog/-/blogs/4639517
All hook projects will be like abc-hook
To make any change in any existing functionality of liferay we use hook. For ex. if u want to modify login jsp then u can use login-hook.. The name is up to you..
Note:- creating a hook for your custom portlet is not preferred, better change your code rather than adding a hook for it.
so we will create a hook for login
Since we have mainly 4 hooks:
1. custom-jsp
2. portal-properties
3. language
4. service
Steps for creating a custom-jsp hook:-
1. Open your IDE.
2. Go to File->New->Liferay Project
3. Choose HOOK in Plugin Type and Finish.
4. After this GoTo the package explorer and then to your Project (login-hook) Right-Click, in the drop-down menu select new->Liferay hook
5. In the appeared dialog box. check the Custom Jsps hook to create.
6. Select Login.jsp and then click OK.
7. click Finish.
8. Goto \login-hook\custom_jsps\html\portlet\login\login.jsp and add your own modification
like:- add some line "Hi This is my new Login Hook".
like I added herein.
<%@ include file="/html/portlet/login/init.jsp" %>
<c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>">
<%
String signedInAs = HtmlUtil.escape(user.getFullName());
if (themeDisplay.isShowMyAccountIcon()) {
signedInAs = "<a href=\"" + HtmlUtil.escape(themeDisplay.getURLMyAccount().toString()) + "\">" + signedInAs + "</a>";
}
%>
<%= LanguageUtil.format(pageContext, "you-are-signed-in-as-x", signedInAs) %>
</c:when>
<c:otherwise>
<%
String redirect = ParamUtil.getString(request, "redirect");
String login = LoginUtil.getLogin(request, "login", company);
String password = StringPool.BLANK;
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
if (Validator.isNull(authType)) {
authType = company.getAuthType();
}
%>
<portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL">
<portlet:param name="saveLastPath" value="0" />
<portlet:param name="struts_action" value="/login/login" />
</portlet:actionURL>
"Hi This is my new Login Hook".
<aui:form action="<%= loginURL %>" method="post" name="fm">
<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
<c:if test='<%= SessionMessages.contains(request, "user_added") %>'>
<%
String userEmailAddress = (String)SessionMessages.get(request, "user_added");
String userPassword = (String)SessionMessages.get(request, "user_added_password");
%>
<div class="portlet-msg-success">
<c:choose>
<c:when test="<%= company.isStrangersVerify() || Validator.isNull(userPassword) %>">
<%= LanguageUtil.format(pageContext, "thank-you-for-creating-an-account-your-password-has-been-sent-to-x", userEmailAddress) %>
</c:when>
<c:otherwise>
<%= LanguageUtil.format(pageContext, "thank-you-for-creating-an-account-your-password-is-x", new Object[] {userPassword, userEmailAddress}, false) %>
</c:otherwise>
</c:choose>
</div>
</c:if>
.......................(ctd)
9. Deploy the hook.
You can see the login Portlet showing the changes you made....
Thanks
http://www.liferay.com/web/jonas.yuan/blog/-/blogs/4639517
All hook projects will be like abc-hook
To make any change in any existing functionality of liferay we use hook. For ex. if u want to modify login jsp then u can use login-hook.. The name is up to you..
Note:- creating a hook for your custom portlet is not preferred, better change your code rather than adding a hook for it.
so we will create a hook for login
Since we have mainly 4 hooks:
1. custom-jsp
2. portal-properties
3. language
4. service
Steps for creating a custom-jsp hook:-
1. Open your IDE.
2. Go to File->New->Liferay Project
3. Choose HOOK in Plugin Type and Finish.
4. After this GoTo the package explorer and then to your Project (login-hook) Right-Click, in the drop-down menu select new->Liferay hook
5. In the appeared dialog box. check the Custom Jsps hook to create.
6. Select Login.jsp and then click OK.
7. click Finish.
8. Goto \login-hook\custom_jsps\html\portlet\login\login.jsp and add your own modification
like:- add some line "Hi This is my new Login Hook".
like I added herein.
<%@ include file="/html/portlet/login/init.jsp" %>
<c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>">
<%
String signedInAs = HtmlUtil.escape(user.getFullName());
if (themeDisplay.isShowMyAccountIcon()) {
signedInAs = "<a href=\"" + HtmlUtil.escape(themeDisplay.getURLMyAccount().toString()) + "\">" + signedInAs + "</a>";
}
%>
<%= LanguageUtil.format(pageContext, "you-are-signed-in-as-x", signedInAs) %>
</c:when>
<c:otherwise>
<%
String redirect = ParamUtil.getString(request, "redirect");
String login = LoginUtil.getLogin(request, "login", company);
String password = StringPool.BLANK;
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
if (Validator.isNull(authType)) {
authType = company.getAuthType();
}
%>
<portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL">
<portlet:param name="saveLastPath" value="0" />
<portlet:param name="struts_action" value="/login/login" />
</portlet:actionURL>
"Hi This is my new Login Hook".
<aui:form action="<%= loginURL %>" method="post" name="fm">
<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
<c:if test='<%= SessionMessages.contains(request, "user_added") %>'>
<%
String userEmailAddress = (String)SessionMessages.get(request, "user_added");
String userPassword = (String)SessionMessages.get(request, "user_added_password");
%>
<div class="portlet-msg-success">
<c:choose>
<c:when test="<%= company.isStrangersVerify() || Validator.isNull(userPassword) %>">
<%= LanguageUtil.format(pageContext, "thank-you-for-creating-an-account-your-password-has-been-sent-to-x", userEmailAddress) %>
</c:when>
<c:otherwise>
<%= LanguageUtil.format(pageContext, "thank-you-for-creating-an-account-your-password-is-x", new Object[] {userPassword, userEmailAddress}, false) %>
</c:otherwise>
</c:choose>
</div>
</c:if>
.......................(ctd)
9. Deploy the hook.
You can see the login Portlet showing the changes you made....
Thanks
Hey can you please let me know that when we create it , under which category my portlet is visible.
ReplyDeleteTools->SignIn portlet
ReplyDeleteThanks it is very simple and easy to understand
ReplyDeleteGood day! This is my 1st comment here so I just wanted to give a quick shout out and tell you I genuinely enjoy reading through your blog posts.
ReplyDeleteCan you recommend any other blogs/websites/forums that go over the same
subjects? Thanks!
Also visit my blog engine optimization search seo services (http://usahausaha.com/activity/p/21223)