Forums de discussion

Hooks. Changing directory structure of a folder in Eclipse

Alessandro Violante, modifié il y a 11 années.

Hooks. Changing directory structure of a folder in Eclipse

New Member Publications: 9 Date d'inscription: 25/10/12 Publications récentes
Hi,

Searching in the guide for Hooks, i was trying to to my first example hook.

At the beginning it is wrote that you have to

"The directory
structure inside this folder must mirror the one within liferay-portal-
[version]/tomcat-6.0.26/webapps/ROOT. To override the Terms of Use, copy liferayportal-[
version]/tomcat-6.0.26/webapps/ROOT/html/portal/terms_of_use.jsp to
hooks/example-hook/docroot/META-INF/custom_
jsps/html/portal/terms_of_use.jsp."

What are you talking about when you say to change the directory structure of a folder?

If my structure is META-INF/custom_jsps, what i have to change and where? What does it mean?

liferayportal-[version] is the name of my workspace, right?

Alex
thumbnail
David H Nebinger, modifié il y a 11 années.

RE: Hooks. Changing directory structure of a folder in Eclipse

Liferay Legend Publications: 14918 Date d'inscription: 02/09/06 Publications récentes
Basically you must be aware of how the hook deployment works...

JSP hooks replace the JSPs of the portal w/ your hooked version. In order to replace files, the hook's directory structure must match that of the portal's.

So first you should not be putting the JSPs into the META-INF directory.

Your hook will initially have a docroot directory. In this directory you'd add your custom_jsps directory.

From this directory you build up the directories so the paths match that of root.

So to override the /html/portal/terms_of_use.jsp you're going to end up with a directory in your hook of /docroot/custom_jsps/html/portal/terms_of_use.jsp. You'll make your changes in this file.

When the hook is deployed, it will replace the portal's terms of use jsp page with your own.

If you did not mirror the portal's directory, i.e. you created /docroot/custom_jsps/terms_of_use.jsp, when you deployed your hook the portal's page would be untouched and if you navigated to the webapps/ROOT directory you'd find a new /webapps/ROOT/terms_of_use.jsp page but this page would not be used by the portal.
thumbnail
Apoorva Prakash, modifié il y a 11 années.

RE: Hooks. Changing directory structure of a folder in Eclipse

Liferay Master Publications: 658 Date d'inscription: 15/06/10 Publications récentes
Yes David, exactly right... just one addition from my side in your words, correct me if I'm wrong...

If we are overriding the terms_of_use.jsp, then the default file from \ROOT\html\portal is renamed as terms_of_use.portal.jsp and our Hook's file is replaced instead with default name.

But I still wonder, what is the standard procedure, if we are removing the customized file form hook, apart from removing the Hook's file, and rename the old one form terms_of_use.portal.jsp to terms_of_use.jsp in server.

Thanks,
Apoorva Prakash
thumbnail
David H Nebinger, modifié il y a 11 années.

RE: Hooks. Changing directory structure of a folder in Eclipse

Liferay Legend Publications: 14918 Date d'inscription: 02/09/06 Publications récentes
Apoorva Prakash:
If we are overriding the terms_of_use.jsp, then the default file from \ROOT\html\portal is renamed as terms_of_use.portal.jsp and our Hook's file is replaced instead with default name.


Well, this occurs, but not through anything you define in your hook.

When your hook is deployed, Liferay will rename the terms_of_use.jsp to terms_of_use.jsp to terms_of_use.liferay.jsp and put your file in it's original place.

When your hook is undeployed, Liferay will remove your terms_of_use.jsp page and restore the original terms_of_use.liferay.jsp back to terms_of_use.jsp.

This whole process ensures that there will always be the terms_of_use.jsp page that the portal is coded to look for whether your hook is deployed or not.
thumbnail
Apoorva Prakash, modifié il y a 11 années.

RE: Hooks. Changing directory structure of a folder in Eclipse

Liferay Master Publications: 658 Date d'inscription: 15/06/10 Publications récentes
David H Nebinger:
Apoorva Prakash:
If we are overriding the terms_of_use.jsp, then the default file from \ROOT\html\portal is renamed as terms_of_use.portal.jsp and our Hook's file is replaced instead with default name.


Well, this occurs, but not through anything you define in your hook.

When your hook is deployed, Liferay will rename the terms_of_use.jsp to terms_of_use.jsp to terms_of_use.liferay.jsp and put your file in it's original place.

When your hook is undeployed, Liferay will remove your terms_of_use.jsp page and restore the original terms_of_use.liferay.jsp back to terms_of_use.jsp.

This whole process ensures that there will always be the terms_of_use.jsp page that the portal is coded to look for whether your hook is deployed or not.


Hello David,

Its quite nicely explained.

Thanks and Regards,
Apoorva Prakash
thumbnail
Apoorva Prakash, modifié il y a 11 années.

RE: Hooks. Changing directory structure of a folder in Eclipse

Liferay Master Publications: 658 Date d'inscription: 15/06/10 Publications récentes
Hello Alessandro,

You are just a bit confused, not a big deal... Just take it easy...

See the hooks development wiki here, and if you are using Liferay IDE see this.

Check them, and they will definitely help you...

Thanks and Regards,
Apoorva Prakash