Provide page in the context of StreamField blocks
See original GitHub issueI came across the limitation that the page is missing in the context of related StreamField blocks when rendering the blocks template several times. A typical use case is when you need to implement an intro block, where the page title and author should be displayed.
So far I was not able to solve this as a complete StreamField block. My implementation is a StreamField block anyway, but not using the blocks rendering mechanism. Instead I check for this block type and call a template with {% include %}
and the necessary data as parameters.
The hurdle occurs in the majority of cases when you need to display data from builtin fields of Wagtails Page
model. Otherwise you would be able to design it like it should be.
This issue is opened in addition to #1743 to clearly separate the discussion between the different requirements to have request
and page
available in the template context. I fully agree with https://github.com/torchbox/wagtail/issues/1743#issuecomment-144029475, though.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top GitHub Comments
I agree, and the parent block (if any) would also be extremely useful in a lot of cases.
Closing this now, as the specific issue described here is fixed by #2786 (even if there is further work to do on the feature as a whole).