SharePoint site filtering

IM 1 Reputation point
2022-09-28T13:19:38.407+00:00

Hi folks,

I have an issue with Microsoft Modern SharePoint Online.

I would like to use the webpart or an app to dynamically filter and show sites from hubsite. For example by name or special column.
This is necessary to display sites of open and closed projects

Thanks a lot!

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,791 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenXu-MSFT 16,561 Reputation points Microsoft Vendor
    2022-09-29T02:49:23.01+00:00

    Hi @IM ,

    I would suggest the you can use PnP Modern Search v4 to dynamically search within the hub site.

    • Add PnP - Search Box and PnP - Search Results to the page, edit Search Results web part and use KQL filters DepartmentId:"{hubSiteId}" or DepartmentId:{{PageContext.hubSiteId}} on the hub site.
      245845-image.png
    • Connect Search Box to Search Results.
      245816-image.png

    After finishing this, the Search Results will only return results within the sites of a hubsite when searching in Search Box.

    To install and get started with PnP modern search, see these:

    To retrieve the hubsiteId of a specific hub site, you can use the PowerShell command Get-SPOHubSite or via a SharePoint API call: /_api/site?$select=IsHubSite,HubSiteId.

    ----------

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.