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 subcategories on the threads page.
This hook can be imported from misago.threads.hooks:
from misago.threads.hooks import get_threads_page_subcategories_hookdef custom_get_threads_page_subcategories_filter(
action: GetThreadsPageSubcategoriesHookAction, request: HttpRequest
) -> dict | None:
...A function implemented by a plugin that can be registered in this hook.
Next function registered in this hook, either a custom function or Misago's standard one.
See the action section for details.
The request object.
A Python dict with data for the categories list component.
Must have at least two keys: categories and template_name:
{
"categories": ...,
"template_name": "misago/thread_list/subcategories.html"
}To suppress categories lists on a page, return None.
def get_threads_page_subcategories_action(request: HttpRequest) -> dict | None:
...Misago function used to build a dict with data for the categories list component, used to display the list of subcategories on the threads page.
The request object.
A Python dict with data for the categories list component.
Must have at least two keys: categories and template_name:
{
"categories": ...,
"template_name": "misago/category_thread_list/subcategories.html"
}To suppress categories lists on a page, return None.
The code below implements a custom filter function that replaces full subcategories component's template with a custom one
from django.http import HttpRequest
from misago.categories.models import Category
from misago.threads.hooks import get_threads_page_subcategories_hook
@get_threads_page_subcategories_hook.append_filter
def customize_subcategories_template(action, request: HttpRequest) -> dict | None:
data = action(request)
data["template_name"] = "plugin/subcategories.html"
return data