From 54647bda2c8c8055fd03de34f649c39a5b4edaa8 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 5 Oct 2023 22:51:41 +0100 Subject: [PATCH] Move construct_page_listing_buttons hook docs into the 'Page explorer' section --- docs/reference/hooks.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/reference/hooks.md b/docs/reference/hooks.md index 8bbfa3a8a9..6ef0307542 100644 --- a/docs/reference/hooks.md +++ b/docs/reference/hooks.md @@ -833,23 +833,6 @@ def make_publish_default_action(menu_items, request, context): break ``` -(construct_page_listing_buttons)= - -### `construct_page_listing_buttons` - -Modify the final list of page listing buttons in the page explorer. The callable passed to this hook receives a list of `PageListingButton` objects, a page, a user object, and a context dictionary, and should modify the list of listing items in-place. - -```python -@hooks.register('construct_page_listing_buttons') -def remove_page_listing_button_item(buttons, page, user, context=None): - if page.is_root: - buttons.pop() # removes the last 'more' dropdown button on the root page listing buttons -``` - -```{versionchanged} 5.2 -The hook function now receives a `user` argument instead of a `page_perms` argument. To check the user's permissions on the page, use `page.permissions_for_user(user)`. -``` - (construct_wagtail_userbar)= ### `construct_wagtail_userbar` @@ -1110,6 +1093,23 @@ def page_custom_listing_more_buttons(page, page_perms, next_url=None): The template for the dropdown button can be customised by overriding `wagtailadmin/pages/listing/_button_with_dropdown.html`. Make sure to leave the dropdown UI component itself as-is. +(construct_page_listing_buttons)= + +### `construct_page_listing_buttons` + +Modify the final list of page listing buttons in the page explorer. The callable passed to this hook receives a list of `PageListingButton` objects, a page, a user object, and a context dictionary, and should modify the list of listing items in-place. + +```python +@hooks.register('construct_page_listing_buttons') +def remove_page_listing_button_item(buttons, page, user, context=None): + if page.is_root: + buttons.pop() # removes the last 'more' dropdown button on the root page listing buttons +``` + +```{versionchanged} 5.2 +The hook function now receives a `user` argument instead of a `page_perms` argument. To check the user's permissions on the page, use `page.permissions_for_user(user)`. +``` + ## Page serving (before_serve_page)=