Forum Discussion

itadhkbn's avatar
11 years ago

Hide the "Show All" option

I want to limit the users to post new topic within the same category. 
But I found that when the user click the "Show All" option, they can select the boards at the other category. 

How can I hide the "Show All" option at the board selection menu ?

Please help to provide some sample code for reference. Thanks.

 

board.png

  • Hi itadhkbn , 

     

    in one of my projects, I used JavaScript to remove the "show all", just create a component with the following JavaScript code and add it to PostPage.

     

    <@liaAddScript>
    ....
    ....    
        function  removeShowAll () {
            var boardObj = document.getElementById('lia-board');
            for(var i=0; i < boardObj.options.length; i++) {
                if(boardObj.options[i].value == "$more$" ) {
                    boardObj.remove(i);
                    return true;
                }           
            }
        } 
    
    </@liaAddScript>

     

     

    be careful with this removal, as the dropdown list shows 20 boards, you can't see all boards there if you have more than 20 boards, you may consider to increase the number under 

    Admin->features->ask a question->number of boards to display

     

  • Hi Haidong. Thanks for your reply.

     

    FYI. I have used the below code to hide the option.

     

    <script type="text/javascript">
    if ($("#lia-board option:last").val()=="$more$"){
    $("#lia-board option[value='$more$']").remove();
    }
    </script>

  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)

    Hi itadhkbn , 

     

    in one of my projects, I used JavaScript to remove the "show all", just create a component with the following JavaScript code and add it to PostPage.

     

    <@liaAddScript>
    ....
    ....    
        function  removeShowAll () {
            var boardObj = document.getElementById('lia-board');
            for(var i=0; i < boardObj.options.length; i++) {
                if(boardObj.options[i].value == "$more$" ) {
                    boardObj.remove(i);
                    return true;
                }           
            }
        } 
    
    </@liaAddScript>

     

     

    be careful with this removal, as the dropdown list shows 20 boards, you can't see all boards there if you have more than 20 boards, you may consider to increase the number under 

    Admin->features->ask a question->number of boards to display

     

    • itadhkbn's avatar
      itadhkbn
      Guide

      Hi Haidong. Thanks for your reply.

       

      FYI. I have used the below code to hide the option.

       

      <script type="text/javascript">
      if ($("#lia-board option:last").val()=="$more$"){
      $("#lia-board option[value='$more$']").remove();
      }
      </script>

      • HaidongG's avatar
        HaidongG
        Lithium Alumni (Retired)

        Hi itadhkbn ,

         

        It seems that your community has included JQuery libraries directly, your code looks great and simpler!