Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide Showing result text in liferay Search Container?

I am using liferay search container to display list of information, but in that liferay search container by default display number of records like "Showing 2 results". But in my case i don't want to display this. How can I remove this? Also attached the image of search container.

enter image description here

Suggestions are welcome.

like image 901
Scorpion Avatar asked Jun 06 '12 06:06

Scorpion


4 Answers

You can do this with Javascript as suggested by Felix Christy:

Here are the quick steps :

  • Go to "Manage Page" section of the desired page (page on which you dont want to show this text)
  • Go to javascript section add the following, its Alloy UI javascript framework which comes bundled with liferay:

    AUI().ready(        
    
        function(customA) {
            customA.all('.taglib-page-iterator').hide(); // this would hide **all** the elements which have the class "taglib-page-iterator"
        }
    );
    
  • The above javascript code can be included in the custom portlet's JSP itself (note the method and selector which I have changed), like:

    <aui:script>
        AUI().ready(        
    
            function(customA) {
                customA.one('#my-portletID .taglib-page-iterator').hide(); // this would hide only **one** element (the first it finds) which has the css class "taglib-page-iterator" under an element with id="my-portletID".
            }
        );
    </aui:script>
    

Another possible solution through Hook:

You can create a hook as mentioned by Sandeep Nair to hide the results-text but you can put a condition to check to hide only if the URL of the page is for which you want to hide this or can have a condition to check for the particular portlet you want to hide this result-text.

So it will work normally for other pages and portlet, but will hide for your page and certain portlets which you define. This is an idea and have not tried it yet, but I think it would work. You can use the themeDisplay object which is available on JSP pages to retrieve the portlet-id.

Hope this helps.

Thanks to Felix Christy for suggesting the solution through Javascript.

I thought of converting my comments to an answer for better visibility to other members of this wonderful community.

like image 122
Prakash K Avatar answered Oct 18 '22 23:10

Prakash K


It is because you are using page-iterator in your search container. When the records exceeds the default delta the message above will be replaced by showing-x-of-y-results alongside page numbers and controls for navigating to next pages.

If you dont want this then you have to modify the jsp page using hook. The name of the jsp is showing_x_results.jspf and following snippet is what you are looking for to modify in that.

<c:otherwise>
            <c:choose>
                <c:when test="<%= total != 1 %>">
                    <%= LanguageUtil.format(pageContext, "showing-x-results", numberFormat.format(total)) %>
                </c:when>
                <c:otherwise>
                    <%= LanguageUtil.format(pageContext, "showing-x-result", numberFormat.format(total)) %>
                </c:otherwise>
            </c:choose>
        </c:otherwise>
like image 30
Sandeep Nair Avatar answered Oct 19 '22 00:10

Sandeep Nair


In order to remove that String for some specific page, please put a jQuery/javascript on the page, which will hide that particular div/span which is showing that text.

In this case, it will not be shown on that page, but it will be available and will be rendered elsewhere.

Here are the quick steps :

  1. Go to "Manage Page" section of the desired page (page on which you dont want to show this text)
  2. Go to javascript section add this $('.taglib-page-iterator').hide();

This will only work, if you have included jquery.js in your theme. So please do it.

like image 3
Felix Christy Avatar answered Oct 18 '22 23:10

Felix Christy


At present, hook (or ext if you want an extreme solution) is the only way you can do it. Override the showing_x_results.jspf Fragment and comment/remove what's unnecessary. The only "properties" that are configurable through the portal-ext.properties are these (LR 6.0.5)

    #
    # Set the available values for the number of entries to display per page. An
    # empty value, or commenting out the value, will disable delta resizing.
    # The default of 20 will apply in all cases.
    #
    # Always include 20, since it is the default page size when no delta is
    # specified. The absolute maximum allowed delta is 200.
    #
    search.container.page.delta.values=5,10,20,30,50,75

    #
    # Set the maximum number of pages available above and below the currently
    # displayed page.
    #
    search.container.page.iterator.max.pages=25

    #
    # Set this to false to remove the pagination controls above or below
    # results.
    #
    search.container.show.pagination.top=true
    search.container.show.pagination.bottom=true

You can find the latest (LR 6.1GA) Search Container properties explained here: http://www.liferay.com/es/documentation/liferay-portal/6.1/user-guide/-/ai/search-container

I wouldn't recommend hiding it from the client end as it will most likely break if you decide to upgrade your Liferay Installation. Hook is a safe way out.

like image 3
Ashok Goli Avatar answered Oct 18 '22 23:10

Ashok Goli