Clay Banks
Clay Banks

Reputation: 4591

Adding value="Empty Text" to Search Portlet

What I'm simply trying to do is add an empty text string to the Search Portlet Search Bar, basically I want to accomplish this:

<div id="myportlet"> //(or however it's rendered)
    <input type="text "id="search" value="Search Here">
</div>

Edit: Following Pankaj's advice, I placed the placeholder tag in each instance of aui:input, and restarted my server but have yet to see my changes.

<aui:input name="<%= SearchContainer.DEFAULT_CUR_PARAM %>" type="hidden"  value="<%= ParamUtil.getInteger(request, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_CUR) %>" placeholder="Search Portal1"/>
    <aui:input name="format" type="hidden" value="<%= format %>" placeholder="Search Portal "/>

    <aui:fieldset id="searchContainer">
        <aui:input autoFocus="<%= windowState.equals(WindowState.MAXIMIZED) %>"  inlineField="<%= true %>" label="" name="keywords" size="30" value="<%= HtmlUtil.escape(keywords) %>" placeholder="Search Portal3"/>

        <aui:input inlineField="<%= true %>" label="" name="search" src='<%= themeDisplay.getPathThemeImages() + "/common/search.png" %>' title="search" type="image" placeholder="Search Portal4"/>

        <aui:input inlineField="<%= true %>" label="" name="clearSearch" src='<%= themeDisplay.getPathThemeImages() + "/common/close.png" %>' title="clear-search" type="image" placeholder="Search Portal5"/>

Any help?

Thanks!

Upvotes: 0

Views: 1083

Answers (3)

Daniele Baggio
Daniele Baggio

Reputation: 2257

Clay Banks has write well but using jQuery.

In Liferay it's better to use AlloyUI, the js embedded framework bassed on YUI3.

<aui:script>

var A = AUI();

A.one('#specific_div input[type="text"]').attr(''placeholder', 'Some Text!');

</aui:script>

p.s. check the sintax..

Upvotes: 2

Clay Banks
Clay Banks

Reputation: 4591

What I did was simply target the input element with some javascript and gave it an .attr() function, like so:

$('#specific_div input[type="text"]').attr('placeholder', 'Some Text!');

To me, this is a more efficient process because you can instantiate the search portlet many times in one portal (.vm) using $theme.search() and alter each one individually instead of changing the entire search.jsp file.

Upvotes: 0

Pankaj Kathiriya
Pankaj Kathiriya

Reputation: 4210

You can override /docroot/html/portlet/search/search.jsp in hook and provide placeholder attribute to aui input tag of search field.

HTH Regards

Upvotes: 0

Related Questions