This hook wraps the standard function that Misago uses to get the template context data for the threads page.
This hook can be imported from misago.threads.hooks:
from misago.threads.hooks import get_threads_page_context_data_hookdef custom_get_threads_page_context_data_filter(
action: GetThreadsPageContextDataHookAction,
request: HttpRequest,
kwargs: dict,
) -> dict:
...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 view's keyword arguments.
A Python dict with context data to use to render the threads page.
def get_threads_page_context_data_action(request: HttpRequest, kwargs: dict) -> dict:
...Misago function used to get the template context data for the threads page.
The request object.
A Python dict with view's keyword arguments.
A Python dict with context data to use to render the threads page.
The code below implements a custom filter function that adds custom context data to the threads page:
from django.http import HttpRequest
from misago.threads.hooks import get_threads_page_context_data_hook
@get_threads_page_context_data_hook.append_filter
def include_custom_context(action, request: HttpRequest, kwargs: dict) -> dict:
context = action(request, kwargs)
context["plugin_data"] = "..."
return context