how to hide Showing result text in liferay Search Container?
Asked Answered
R

4

7

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.

Rage answered 6/6, 2012 at 6:51 Comment(0)
A
6

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.

Aretina answered 7/6, 2012 at 2:59 Comment(6)
Thanks for your answer..its working fine but what happen is when the page is loading for 1-2 second its showing the Showing x result div and then it will gone. can you tell me why is it so? is it because that div will be loaded first and then it will be hide?Rage
yes it is because the html will be loaded first and then the javascript would run to hide it. I can think of another solution as well, will edit my answer a little.Aretina
Also face one more problem, if i put Document Library above my portlet. Then in DocumentLibrary search container it will hide the Showing x result but in my portlet it will show that. How to resolve this?Rage
You want to hide the results-line for all portlets in that particular page or just for your own portlet in that page or you want to hide it for your portlet anywhere you put it?Aretina
I just want to hide it in my portlet anywhere i put it. right now above my portlet there is Document Library portlet is there. So when i test your code i face that problem.Rage
Through javascript it is good but you would have to do it for every page you put your portlet on. Also you can include the javascript in your portlet code itself or use the hook solution I have described. I will edit my answer to have these possibilitiesAretina
S
4

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>
Spokeshave answered 6/6, 2012 at 7:24 Comment(1)
Is it possible that it can be change within portlet by some property or parameter? Because if i do changes in hook then it will be apply to every search container in my project but i want this in one search container only...Rage
P
3

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.

Pfeifer answered 6/6, 2012 at 8:56 Comment(5)
Can you please provide me some more details on how to achieve that using Jquery/Javascript. Can you please provide code snippet kindly..Rage
You can do this using Alloy UI instead of jQuery which comes bundled with liferay. In place of jQuery code write: var customA = AUI(); customA.one('.taglib-page-iterator').hide(); I have not checked if the class mentioned is right or not but this code would work. No need to include jQuery if you don't want to.Aretina
Agree with Prakash, jQuery is not officially supported by Liferay, Alloy is bundled with LiferaryPfeifer
@PrakashK u r code is working fine...but once i refreshed the page showing result appears again..Obed
I have converted my comments as an answer with additional information.Aretina
D
3

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.

Dodecasyllable answered 6/6, 2012 at 13:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.