Forum Discussion

VikasB's avatar
VikasB
Boss
8 years ago

Exclude message from hidden boards in search results

We are trying to exclude messages from boards which have the setting as "Hide message in this board from the list".  But it includes the hidden board's messages in search results. I assume this setting works no more. 

  • satya's avatar
    satya
    8 years ago

    Hi VikasB,

     

    There is a partial solution where you can adjust the default see and read permissions for hidden boards to deny. So, that admins can get the results but not normal/regular users. For more info you can just go through this link

     

    Just sharing my thought :)

     

    Thanks,

    Srujana Satya

  • VikasB's avatar
    VikasB
    8 years ago

    Hi satya Thanks. But yes, it partial solution. It would not work when I want to exclude the messages from some specific boards in recent post widget but want to keep those boards accessible to end users. In such cases I do not think so there would be any other option than manually exclude those boards like below. 

    <#assign excIds = ["Id1", "Id2","Id3"] />  //boards ids from which messages need to be excluded
    <#assign msgs= rest( "2.0", "/search?q=" + "select * from messages order by post_time desc"?url).data />
    <#list msgs.items as msg>
    <#if excIds?seq_index_of(msg.board.id)== -1 >
    //do something here
    </#if>
    </#list>

7 Replies

  • Hi,

    I'd also like it to work in this way but i dont think this feature excludes the content from search just widgets/lists?

    But if it did i'd find this very useful, so i wait with bated breath for someone in the know to comment.

    Stephen
  • satya's avatar
    satya
    Expert
    8 years ago

    Hi VikasB,

     

    There is a partial solution where you can adjust the default see and read permissions for hidden boards to deny. So, that admins can get the results but not normal/regular users. For more info you can just go through this link

     

    Just sharing my thought :)

     

    Thanks,

    Srujana Satya

  • Thanks, thats a solid suggestion for my speciffic usecase i need to exclude from search but keep it in my site nav :(

    I'm currently using a series of dead boards and redirects to mask content but keep somethign in nav/lists...
  • VikasB's avatar
    VikasB
    Boss
    8 years ago

    Hi satya Thanks. But yes, it partial solution. It would not work when I want to exclude the messages from some specific boards in recent post widget but want to keep those boards accessible to end users. In such cases I do not think so there would be any other option than manually exclude those boards like below. 

    <#assign excIds = ["Id1", "Id2","Id3"] />  //boards ids from which messages need to be excluded
    <#assign msgs= rest( "2.0", "/search?q=" + "select * from messages order by post_time desc"?url).data />
    <#list msgs.items as msg>
    <#if excIds?seq_index_of(msg.board.id)== -1 >
    //do something here
    </#if>
    </#list>
  • satya's avatar
    satya
    Expert
    8 years ago

    Hi VikasB,

     

    Thank you for the code sample which works not to fetch the data from the hidden boards through API. But will it work for the search results exclusion(from hidden boards)in the community search? If yes, can you please let me know?

     

    Thanks,
    Srujana Satya

     

     

     

     

     

  • VikasB's avatar
    VikasB
    Boss
    8 years ago

    Hi satya There are two use cases I am working on

    1. In Search Result: I do not want to fetch the results from boards whose setting is "hide messages in this board from the lists" and do not want to show those boards to end users.
      In this case your solution would work perfectly.
    2. In Custom Recent Post Widget: I do not want to fetch the posts from boards A, B, and C and also I want to show these boards to end users as well. 
      Here your solution would not work as I can not set no such permission at back end. So in this case I have to use that code block. 

    But It would be great if you LMK the significance of the setting "hide messages in this board from the lists". When I hit an API "select * from messages" it also fetches the posts from all boards even you applied this setting.
     

     

  • satya's avatar
    satya
    Expert
    8 years ago

    Hi VikasB,

     

    Yes, I got your point on two use cases. Previously I have worked on a requirement where we have customised the "Recent posts" widget by calling the V2 API call. But the same thing happened to us, we are able to fetch all the messages (including messages from the hidden boards). So, we have denied the see/read posts permissions for hidden boards, which lead normal users can't view the posts recent posts from hidden boards in the Latest posts widget(but admins do).

     

    So, when I went through your post I thought it may be a partial solution for your use case. But yes, the code sample you have provided is a great one which does not allow the data from hidden boards. 

     

    I was also looking for a requirement to exclude the search results from hidden boards. So I am just curious to know that you have any Idea on same use case by using any freemarker code other than denying the permissions  :) 

     

    Hope you got my curiosity :)

     

    Thanks,

    Srujana Satya