You create dynamic page hooks to add custom logic during the page routing and loading process. Use hooks to validate requests, modify data queries, customize responses, or update sitemaps for dynamic pages.
Make sure you have:
routers.js file.beforeRouter hookTo add a beforeRouter() hook on dynamic pages with the listings prefix, add the following code to your routers.js file. A beforeRouter hook needs to return a router response object.
This hook restricts admin pages to visitors with the admin role:
customizeQuery hookTo add a customizeQuery() hook on dynamic pages with the listings prefix, add the following code to your routers.js file. A customizeQuery hook needs to return a data query object.
This hook shows only active real estate listings to non-admin visitors:
afterRouter hookTo add an afterRouter() hook on dynamic pages with the listings prefix, add the following code to your routers.js file. An afterRouter hook needs to return a router response object.
This hook redirects unavailable listings and uses custom templates for featured listings: