0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Move construct_page_listing_buttons hook docs into the 'Page explorer' section

This commit is contained in:
Matt Westcott 2023-10-05 22:51:41 +01:00
parent 0ae8d5fc8c
commit 54647bda2c

View File

@ -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)=