Skip to content

Latest commit

 

History

History
92 lines (53 loc) · 1.98 KB

File metadata and controls

92 lines (53 loc) · 1.98 KB

get_categories_page_component_hook

This hook wraps the standard function that Misago uses to build a dict with data for the categories list component, used to display the list of categories on the categories page.

Location

This hook can be imported from misago.categories.hooks:

from misago.categories.hooks import get_categories_page_component_hook

Filter

def custom_get_categories_page_component_filter(
    action: GetCategoriesPageComponentHookAction, request: HttpRequest
) -> dict:
    ...

A function implemented by a plugin that can be registered in this hook.

Arguments

action: GetCategoriesPageComponentHookAction

Misago function used to build a dict with data for the categories list component, used to display the list of categories on the categories page.

See the action section for details.

request: HttpRequest

The request object.

Return value

A Python dict with data for the categories list component.

Action

def get_categories_page_component_action(request: HttpRequest) -> dict:
    ...

Misago function used to build a dict with data for the categories list component, used to display the list of categories on the categories page.

Arguments

request: HttpRequest

The request object.

Return value

A Python dict with data for the categories list component.

Must have at least two keys: categories and template_name:

{
    "categories": ...,
    "template_name": "misago/categories/list.html"
}

Example

The code below implements a custom filter function that replaces default categories component with a custom one.

from django.http import HttpRequest
from misago.categories.hooks import get_categories_component_hook


@get_categories_component_hook.append_filter
def custom_categories_list(action, request: HttpRequest) -> dict:
    return {
        "categories": [],
        "template_name": "plugin/categories_list.html",
    }