Foros de discusión

Deactivate select field in search portlet.

thumbnail
lutz Bremen, modificado hace 11 años.

Deactivate select field in search portlet.

Expert Mensajes: 291 Fecha de incorporación: 20/10/11 Mensajes recientes
Hey guys,

I want my search-portlet only to have a textfield and a button. not the usual select field. how can i deactivate this ?
thumbnail
Tejas Kanani, modificado hace 11 años.

RE: Deactivate select field in search portlet.

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
Which Liferay version are you using ?
thumbnail
lutz Bremen, modificado hace 11 años.

RE: Deactivate select field in search portlet.

Expert Mensajes: 291 Fecha de incorporación: 20/10/11 Mensajes recientes
6.1 CE
thumbnail
Tejas Kanani, modificado hace 11 años.

RE: Deactivate select field in search portlet.

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
Check this post, It's having similar kind of question.
http://www.liferay.com/community/forums/-/message_boards/message/12999658
thumbnail
lutz Bremen, modificado hace 11 años.

RE: Deactivate select field in search portlet.

Expert Mensajes: 291 Fecha de incorporación: 20/10/11 Mensajes recientes
yes its nearly the same.... i want the whole selection box not to be shown.
thumbnail
Tejas Kanani, modificado hace 11 años.

RE: Deactivate select field in search portlet.

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
You need to override html/portlet/search/search.jsp using hook.

If you want to search by default in "Everything" then try below code (Not Verified)

<aui:form action="<%= searchURL %>" method="get" name="fm" onsubmit="<%= &quot;event.preventDefault();&quot; %>">
	<liferay-portlet:renderurlparams varImpl="searchURL" />
	<aui:input name="format" type="hidden" value="<%= format %>" />
        [b]<aui:input name="groupId" type="hidden" value="0" />[/b]

	<aui:fieldset>
		<aui:input inlineField="<%= true %>" label="" name="keywords" size="30" value="<%= keywords %>" />

		[b]&lt;%-- Comment out below code --%&gt;[/b]
                [b]&lt;%--[/b] <aui:select inlinefield="<%= true %>" label="" name="groupId">
			<aui:option label="everything" selected="<%= groupId == 0 %>" value="0" />
			<aui:option label="<%= &quot;this-&quot; + (group.isOrganization() ? &quot;organization&quot; : &quot;site&quot;) %>" selected="<%= groupId != 0 %>" value="<%= group.getGroupId() %>" />
		</aui:select>
                [b]--%&gt;[/b]
</aui:fieldset></aui:form>


Else if you want to search only in current community by default then below code should work(Not Verified)


<aui:form action="<%= searchURL %>" method="get" name="fm" onsubmit="<%= &quot;event.preventDefault();&quot; %>">
	<liferay-portlet:renderurlparams varImpl="searchURL" />
	<aui:input name="format" type="hidden" value="<%= format %>" />
        [b]<aui:input name="groupId" type="hidden" value="[i]<%= group.getGroupId() %>[/i]" />[/b]

	<aui:fieldset>
		<aui:input inlineField="<%= true %>" label="" name="keywords" size="30" value="<%= keywords %>" />

		[b]&lt;%-- Comment out below code --%&gt;[/b]
                [b]&lt;%--[/b] <aui:select inlinefield="<%= true %>" label="" name="groupId">
			<aui:option label="everything" selected="<%= groupId == 0 %>" value="0" />
			<aui:option label="<%= &quot;this-&quot; + (group.isOrganization() ? &quot;organization&quot; : &quot;site&quot;) %>" selected="<%= groupId != 0 %>" value="<%= group.getGroupId() %>" />
		</aui:select>
                [b]--%&gt;[/b]
</aui:fieldset></aui:form>


So basically we are just setting groupId field value as per required. If "Everything" then it should be 0 and for current site it should be groupId of that site.

I hope this will be helpful.

Regards,
Tejas
thumbnail
lutz Bremen, modificado hace 11 años.

RE: Deactivate select field in search portlet.

Expert Mensajes: 291 Fecha de incorporación: 20/10/11 Mensajes recientes
cant i jsut hide this field?
thumbnail
Tejas Kanani, modificado hace 11 años.

RE: Deactivate select field in search portlet.

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
Hi Lutz,

Above given code will do the same. If you comment out give line of code(mentioned with "Comment out below code") it will not display search type selection. But as in logic , it will need groupId field value. So in that case I've added one hidden field which will serve our purpose. And it will provide that field value which is required in the same search.jsp
long groupId = ParamUtil.getLong(request, "groupId");

So as per my understanding, simply hiding will not work in this case. As in that case I guess you might not get correct value for groupId.
Cosco S, modificado hace 11 años.

RE: Deactivate select field in search portlet.

New Member Mensajes: 20 Fecha de incorporación: 22/08/12 Mensajes recientes
Hello
Very good your information.
When i write in portal_normal.vm $theme.search, now I see a small search box( input text +select+ button ), do you know where can i customize this box? . Im trying with a hook but i can't. . Could you please help me? What file i need to rewrite?

Thank you
Cosco S, modificado hace 11 años.

RE: Deactivate select field in search portlet.

New Member Mensajes: 20 Fecha de incorporación: 22/08/12 Mensajes recientes
I'm find the solution. I rewrite the directory webapps\ROOT\html\taglib\ui\search in my hook.
I was confused with html/portlet/search/

Bye.
thumbnail
Adnan Yaqoob, modificado hace 8 años.

RE: Deactivate select field in search portlet.

Junior Member Mensajes: 36 Fecha de incorporación: 24/03/14 Mensajes recientes
@Tejas
The code for forms and fieldset doesn't exists in 'html/portlet/search/search.jsp'.
Are you referring 'html/taglib/ui/search/start.jsp'? Since I find similar code here