Purpose
Our exercise has us building a controller that loads an administrator-controlled node when a certain path is used. We want the administrator to be able to select a node to be rendered on the path /thunderdome using twig.
Approach
- Create a module settings page that lists configuration variables for your module
- Create a new configuration variable called something like important_node
- Add an input to the module configuration page. Use an entity_reference field type to select a node on the configuration page.
- Use the new controller to pull in the new configuration variable and then load the node and then render it using a render array
How to
- As an administrator, navigate to the module settings page and select a node.
- As a user (anonymous or admin), navigate to /thunderdome and see the node get rendered.
Review Checklist
-
Sufficient documentation (can others figure out what's going on without context? -
Sufficient test coverage. -
All pipelines pass. -
Added applicable files to code standards and automated test pipelines. -
No merge conflicts present. -
Merge request follows deployment requirements.
Edited by Colby Chiste