Foren

Using search hook for specific site

Ahmad Shakil, geändert vor 8 Jahren.

Using search hook for specific site

New Member Beiträge: 3 Beitrittsdatum: 17.12.13 Neueste Beiträge
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
thumbnail
Jan Geißler, geändert vor 8 Jahren.

RE: Using search hook for specific site

Liferay Master Beiträge: 735 Beitrittsdatum: 05.07.11 Neueste Beiträge
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.
Ahmad Shakil, geändert vor 8 Jahren.

RE: Using search hook for specific site

New Member Beiträge: 3 Beitrittsdatum: 17.12.13 Neueste Beiträge
thanks Jan, but then what is the purpose of Application Adapter?
thumbnail
Jan Geißler, geändert vor 8 Jahren.

RE: Using search hook for specific site

Liferay Master Beiträge: 735 Beitrittsdatum: 05.07.11 Neueste Beiträge
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.
Ahmad Shakil, geändert vor 8 Jahren.

RE: Using search hook for specific site

New Member Beiträge: 3 Beitrittsdatum: 17.12.13 Neueste Beiträge
No shame Jan, i added plateform later in the post ;) thanks anyways emoticon
thumbnail
Adnan Yaqoob, geändert vor 8 Jahren.

RE: Using search hook for specific site

Junior Member Beiträge: 36 Beitrittsdatum: 24.03.14 Neueste Beiträge
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
Bhavin Vora, geändert vor 8 Jahren.

RE: Using search hook for specific site

New Member Beitrag: 1 Beitrittsdatum: 12.02.16 Neueste Beiträge
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.
Helen Morton, geändert vor 8 Jahren.

RE: Using search hook for specific site

New Member Beiträge: 3 Beitrittsdatum: 21.03.16 Neueste Beiträge
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.
thumbnail
Adnan Yaqoob, geändert vor 8 Jahren.

RE: Using search hook for specific site

Junior Member Beiträge: 36 Beitrittsdatum: 24.03.14 Neueste Beiträge
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
Helen Morton, geändert vor 8 Jahren.

RE: Using search hook for specific site

New Member Beiträge: 3 Beitrittsdatum: 21.03.16 Neueste Beiträge
Thanks for the reply Adnan. It's frustrating that there is no documentation on this.
thumbnail
Adnan Yaqoob, geändert vor 8 Jahren.

RE: Using search hook for specific site

Junior Member Beiträge: 36 Beitrittsdatum: 24.03.14 Neueste Beiträge
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
thumbnail
Andre Albert, geändert vor 6 Jahren.

RE: Using search hook for specific site

New Member Beiträge: 13 Beitrittsdatum: 28.03.14 Neueste Beiträge
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