留言板
Using search hook for specific site
Hi,
I have created a site specific search hook by modifying few jsps (start.jsp, search.jsp etc) and adding below setting in liferay-hook.xml
<hook>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
<custom-jsp-global>false</custom-jsp-global>
</hook>
I can see my hook in Application Adapter under Site Settings but if I select hook and apply to my site I cant see jsp changes. However removing <custom-jsp-global>false</custom-jsp-global> make hook works but in this case hook is applied to all sites.
I have included search portlet in theme by below line
$theme.search()
Platform : Liferay 6.2
I have created a site specific search hook by modifying few jsps (start.jsp, search.jsp etc) and adding below setting in liferay-hook.xml
<hook>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
<custom-jsp-global>false</custom-jsp-global>
</hook>
I can see my hook in Application Adapter under Site Settings but if I select hook and apply to my site I cant see jsp changes. However removing <custom-jsp-global>false</custom-jsp-global> make hook works but in this case hook is applied to all sites.
I have included search portlet in theme by below line
$theme.search()
Platform : Liferay 6.2
Jan Geißler,修改在9 年前。
RE: Using search hook for specific site
Liferay Master 帖子: 735 加入日期: 11-7-5 最近的帖子
The whole purpose of hooking jsp's is to make changes, which will affect the whole portal. Even all Instances running on a machine. If you need different behavior for a site you might consider the following approach:
Add a Custom Field to the Site to indicate which behavior you expect. Evaluate the Custom Field in the search.jsp and include based on the Custom Field either the default jsp of liferay or the one modified by you.
Add a Custom Field to the Site to indicate which behavior you expect. Evaluate the Custom Field in the search.jsp and include based on the Custom Field either the default jsp of liferay or the one modified by you.
thanks Jan, but then what is the purpose of Application Adapter?
Jan Geißler,修改在9 年前。
RE: Using search hook for specific site
Liferay Master 帖子: 735 加入日期: 11-7-5 最近的帖子
Uhhh... 6.2 Looks like I haven't read your post properly ;)
Then I will not be able to assist, as I don't have any experience with Application Adapters for now.
Edit: And I just have seem, they are available as from 6.1 ... Shame on me.
Then I will not be able to assist, as I don't have any experience with Application Adapters for now.
Edit: And I just have seem, they are available as from 6.1 ... Shame on me.
Adnan Yaqoob,修改在8 年前。
RE: Using search hook for specific site
Junior Member 帖子: 36 加入日期: 14-3-24 最近的帖子
I'm using 6.2 ee but experiencing the same problem for some of the file with site specific hook. For example, site specific hook not working for following
html/taglib/ui/search/start.jsp
html/portlet/asset_publisher/init-ext.jsp
Any idea? I don't if site hook can work on limited files at least I didn't came across such limitations
Adnan
html/taglib/ui/search/start.jsp
html/portlet/asset_publisher/init-ext.jsp
Any idea? I don't if site hook can work on limited files at least I didn't came across such limitations
Adnan
Hi Ahmad,
I think Following will describe you this behavior.
when you use <custom-jsp-global>false</custom-jsp-global> the solution becomes more complicated. This is because setting <custom-jsp-global>true</custom-jsp-global> makes Liferay rename your hook jsp files rather than renaming the portal's jsp files.
For example, if custom-jsp-global is set to true, which is the default setting, then when I make a hook for a page called top_js.jsp, the portal will rename the original top_js.jsp file to top_js.portal.jsp and my hook file will be used instead of the original.
However, when custom-jsp-global is set to false then the original file stays intact and the jsp hook file is renamed to something that includes the name of the hook like top_js.my-hook.jsp.
I think Following will describe you this behavior.
when you use <custom-jsp-global>false</custom-jsp-global> the solution becomes more complicated. This is because setting <custom-jsp-global>true</custom-jsp-global> makes Liferay rename your hook jsp files rather than renaming the portal's jsp files.
For example, if custom-jsp-global is set to true, which is the default setting, then when I make a hook for a page called top_js.jsp, the portal will rename the original top_js.jsp file to top_js.portal.jsp and my hook file will be used instead of the original.
However, when custom-jsp-global is set to false then the original file stays intact and the jsp hook file is renamed to something that includes the name of the hook like top_js.my-hook.jsp.
Ahmad,
Did you ever determine the problem with Application Adapters for search jsp's? I think I am finding the same thing -- the adapter is applied to the site but it still loads the original jsp, however it works as expected if it is a normal portal-wide hook.
Is there some reason it doesn't work with the search portlet?
Thanks.
Did you ever determine the problem with Application Adapters for search jsp's? I think I am finding the same thing -- the adapter is applied to the site but it still loads the original jsp, however it works as expected if it is a normal portal-wide hook.
Is there some reason it doesn't work with the search portlet?
Thanks.
Adnan Yaqoob,修改在8 年前。
RE: Using search hook for specific site
Junior Member 帖子: 36 加入日期: 14-3-24 最近的帖子Helen Morton:
Ahmad,
Did you ever determine the problem with Application Adapters for search jsp's? I think I am finding the same thing -- the adapter is applied to the site but it still loads the original jsp, however it works as expected if it is a normal portal-wide hook.
Is there some reason it doesn't work with the search portlet?
Thanks.
Helen,
Yes, not all the JSP's work with application adapters. I couldn't find a reference in documentations regarding eligible JSP's but it is confirmed that not all of them works. I've verified this fact 1.) At source code level, 2.) the Liferay support
Hope that clarifies the situation
Regards
Adnan
Thanks for the reply Adnan. It's frustrating that there is no documentation on this.
Adnan Yaqoob,修改在8 年前。
RE: Using search hook for specific site
Junior Member 帖子: 36 加入日期: 14-3-24 最近的帖子
Helen,
Yes- I understand your feelings. Liferay is improving the documentation with time. In fact the documentation level is much better as of today than it was a year or two before. However, it would be great if some documentation or indication is provided for JSP's which are not applicable with application adapters.
However, what you can do is to find whether the file you want to override has a counter part like xxx-ext.jsp? If yes try to override that. Or as someone mentioned on top make use of Custom fields for enabling some feature at site level. Make conditional changes using global hook configuration for the qualified sites (way around for adapter)
Regards,
Adnan
Yes- I understand your feelings. Liferay is improving the documentation with time. In fact the documentation level is much better as of today than it was a year or two before. However, it would be great if some documentation or indication is provided for JSP's which are not applicable with application adapters.
However, what you can do is to find whether the file you want to override has a counter part like xxx-ext.jsp? If yes try to override that. Or as someone mentioned on top make use of Custom fields for enabling some feature at site level. Make conditional changes using global hook configuration for the qualified sites (way around for adapter)
Regards,
Adnan
Adnan Yaqoob:
I couldn't find a reference in documentations regarding eligible JSP's but it is confirmed that not all of them works. I've verified this fact
Hi,
what i found out is that jsp include references wont work because of the modified name. To make this happen, you need to add the jsp including your jsp file to your hook plugin and change the include path to something like /path/to/myfile.my-hook.jsp
This also applies to references jsp part of a searchcontainer markup.
Greetings,
Andre Albert