Overriding Core JSP file using Liferay 7 Hook
There are few scenarios that you might want to modify the JSPs to override which are no longer in Liferay’s core and you can do…

There are few scenarios that you might want to modify the JSPs to override which are no longer in Liferay’s core and you can do core JSP customizations to a specific site.

portal-web/docroot/html

 

As you can see, the above screen represents before you begin crafting a module to override core JSPs.

In the below example you can restrict global vocabularies and categories with in site scope and it was achieved by implementing hook in Liferay 7 environment.

If you’re overriding,

htmltaglibuiasset_categories_selectorpage.jsp

put the overridden JSP in this folder of your module: to achieve it.

long[] groupIds = (long[])request.getAttribute("liferay-ui:asset-categories-selector:groupIds");
if (ArrayUtil.isEmpty(groupIds)) {
groupIds = PortalUtil.getCurrentAndAncestorSiteGroupIds(scopeGroupId);
}
else {
groupIds = PortalUtil.getCurrentAndAncestorSiteGroupIds(groupIds);
}
long grpId = GetterUtil.getLong(PropsUtil.get("extranet.groupid"));
if(grpId==scopeGroupId){
long globalGrpId = GetterUtil.getLong(PropsUtil.get("global.groupid"));
groupIds = ArrayUtil.remove(groupIds, globalGrpId);
}
List<AssetVocabulary> vocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(groupIds);
<aui:script use="liferay-asset-categories-selector">
new Liferay.AssetCategoriesSelector(
{
className: ‘<%= className %>’,
contentBox: ‘#<%= namespace + randomNamespace %>assetCategoriesSelector_<%= vocabulary.getVocabularyId() %>’,
curEntries: ‘<%= HtmlUtil.escapeJS(categoryIdsTitles[1]) %>’,
curEntryIds: ‘<%= categoryIdsTitles[0] %>’,
hiddenInput: ‘#<%= namespace + hiddenInput + StringPool.UNDERLINE + vocabulary.getVocabularyId() %>’,
instanceVar: ‘<%= namespace + randomNamespace %>’,
labelNode: ‘#<%= namespace %>assetCategoriesLabel_<%= vocabulary.getVocabularyId() %>’,
maxEntries: <%= maxEntries %>,
moreResultsLabel: ‘<%= UnicodeLanguageUtil.get(resourceBundle, "load-more-results") %>’,
portalModelResource: <%= Validator.isNotNull(className) && (ResourceActionsUtil.isPortalModelResource(className) || className.equals(Group.class.getName())) %>,
singleSelect: <%= !vocabulary.isMultiValued() %>,
title: ‘<%= UnicodeLanguageUtil.format(request, "select-x", vocabulary.getTitle(locale), false) %>’,
vocabularyGroupIds: ‘<%= StringUtil.merge(groupIds) %>’,
vocabularyIds: ‘<%= String.valueOf(vocabulary.getVocabularyId()) %>’
}
).render();
</aui:script>

You should see the below screen once you have modify the JSPs.