Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7 Search Portlet - Only show journal articles and PDF files as
Hi,1) In liferay 7 search portlet we need to customize to sort the results like title name ect.
2) We need to add the more input fields fileTypess(like adding file tyle .pdf,.docx) and only get file same file types and did not search any other places.in 6.2 start.jsp file added like below files.<aui:input inlineField="<%= true %>" label="File Type (pdf, docx, etc)" name='<%= namespace + "fileExtension" %>' size="30" title="extension" type="text" useNamespace="<%= false %>"/>
and got the value in search.jsp and that value passed in main-search.jsp fileif(Validator.isNotNull(fileExtension) && fileExtension != ""){
Query fileExtensionQuery = StringQueryFactoryUtil.create("entryClassName:com.liferay.portlet.documentlibrary.model.DLFileEntry +extension:"+fileExtension);
BooleanClause fileExtensionClause = BooleanClauseFactoryUtil.create(searchContext, fileExtensionQuery, BooleanClauseOccur.MUST.getName());
booleanClauseList.add(fileExtensionClause);}
if(booleanClauseList.size()>0){
BooleanClause[] booleanClause = new BooleanClause[booleanClauseList.size()];
booleanClause = booleanClauseList.toArray(booleanClause);
searchContext.setBooleanClauses(booleanClause);
//searchContext.setBooleanClauses(new BooleanClause[] {fileExtensionClause,pbDocumentTypeClause});
}
and we got only file extension but in liferay 7 how we will implement same functionality?
we need to implement it only custom portlet and using hook we can implement? if we are able to implement using hook the what steps we need to take care?.
2) We need to add the more input fields fileTypess(like adding file tyle .pdf,.docx) and only get file same file types and did not search any other places.in 6.2 start.jsp file added like below files.<aui:input inlineField="<%= true %>" label="File Type (pdf, docx, etc)" name='<%= namespace + "fileExtension" %>' size="30" title="extension" type="text" useNamespace="<%= false %>"/>
and got the value in search.jsp and that value passed in main-search.jsp fileif(Validator.isNotNull(fileExtension) && fileExtension != ""){
Query fileExtensionQuery = StringQueryFactoryUtil.create("entryClassName:com.liferay.portlet.documentlibrary.model.DLFileEntry +extension:"+fileExtension);
BooleanClause fileExtensionClause = BooleanClauseFactoryUtil.create(searchContext, fileExtensionQuery, BooleanClauseOccur.MUST.getName());
booleanClauseList.add(fileExtensionClause);}
if(booleanClauseList.size()>0){
BooleanClause[] booleanClause = new BooleanClause[booleanClauseList.size()];
booleanClause = booleanClauseList.toArray(booleanClause);
searchContext.setBooleanClauses(booleanClause);
//searchContext.setBooleanClauses(new BooleanClause[] {fileExtensionClause,pbDocumentTypeClause});
}
and we got only file extension but in liferay 7 how we will implement same functionality?
we need to implement it only custom portlet and using hook we can implement? if we are able to implement using hook the what steps we need to take care?.
Hi Any suggestions on this?
Hi Srini,It's not pretty, but you are on the right track. If you re using the old search portlet then pretty much all the logic you need to manipulate can be done in the JSPs. I have created some very custom Search queries (with filters) and Results (grouped by types in tabs for example) simply by reworking the logic in these JSP files.
Are you stuck on something?
Are you stuck on something?