Can I get all existing Pages for a Community using Apex?

I would like to create a custom component to use in Experience Builder, and this component will allow a configurable navigation to another page. I would like to use a dynamic picklist with Apex to get the list of all available pages for the Community we’re currently on.

I couldn’t find any way to get the list of these pages, is there a table that can be queried to get this list of pages/routes ?

I noticed that when editing a NavigationMenu, the list is available but from a private and undocumented API:

/sfsites/sfservice?Method=GetDevelopmentRoutes&siteGuid=4ea01398-f402-44b2-8a41-501673acb466&docGuid=0e43b2a2-3a6e-47eb-cdfd-dae4e589b3e1&siteType=ChatterNetworkPicasso&iscontrib=true&isbuilder=true

I couldn’t find any official API or table to get this.

enter image description here

Answer

The best way to tackle this would be to use the NavigationMenu you mentioned in the builder and then query for those items in your Apex code.

Within the builder you can use a VisualBuilder apex class (DynamicPickList Class) as a targetConfig type to show a dropdown of available NavigationMenus.

<property
  name="navigationName"
  type="String"
  label="Navigation Name"
  datasource="apex://CommunityMenusVisualEditor"
/>

Then within your LWC you can query for the menu with the navigationName (from the targetConfigs) and a similar setup to the az-insurance example app.

Ref: Set Up a Navigation Menu Using Apex

Attribution
Source : Link , Question Author : Fabien Taillon , Answer Author : lu_ke____

Leave a Comment