0

I need a simple way to make some custom variables / settings configurable for an Editor in Drupal 8. They are not related to Drupal, only to the custom project. For instance, the editor shall be able to set an Affiliate ID that will be used in the external links of the site.

In Drupal 7, I would have used Variable: I would have defined some variables and they would have been editable under admin/config/system/variable.

Since Variable has not been ported yet to Drupal 8, I am looking for a simple way to get this done in D8.

One idea I came up with was to define some "Magic Nodes", like node/1 for my first variable, and then use its title to set the value. However, that looks very hacky and unintuitive to me.

Do you have any better idea?

1 Answer 1

1

According to the change record The variable_get/set/del API is now removed you would need to store the settings in configuration. You can make this configuration available to an Editor by providing a Configuration Form or if you only want to add a few fields you can extend an existing configuration form in a form alter hook. For example add the Affilate ID to the Basic Site Settings. Similar to this example for the menu configuration: How to add field to menu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.