Skip to content

Issue #4 #3 Add node reference variable to module configuration

Colby Chiste requested to merge module_settings_add_reference into master

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

  1. Create a module settings page that lists configuration variables for your module
  2. Create a new configuration variable called something like important_node
  3. Add an input to the module configuration page. Use an entity_reference field type to select a node on the configuration page.
  4. 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

  1. As an administrator, navigate to the module settings page and select a node.
  2. 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

Merge request reports