Adding a new option to "Global settings"

Hello,

I’d like to add a new global option from my plugin. I mean the ones that apply to all sites and you can set on the “Global settings” (admin/setting) view. The purpose of this is sharing some properties among all sites of my installation, such as links to other websites, links to social media and other header and footer content.

It would interesting to do so because using theme options forces users to fill in the data for each site. All sites must share a common appearance and such contents, like those links. It would be nice if the global admin could set (and be able to change) them all at once.

The only way I can think of is extending the class SiteForm and using my own factory for ‘Omeka\Form\SettingForm’ or something similar. But this way, if possible, seems inconvenient and twisted.

Is there a way to do this? Or should I just add a view to my own module with a form to set this options?

Thank you!

It might vary a bit depending on where, exactly the data will be set, but something like this will work

$settings = $this->getServiceLocator()->get('Omeka\Settings');

The Omeka\Settings service stores global settings.

The possible gotcha is that not all classes automatically have the getServiceLocator(). If that’s the case for where you want to set the values, you have to add the service via a factory for your class.

You can add things directly to the global settings form with an event, the form.add_elements event.

Just having your own form that saves to the settings table, as Patrick explains, is also possible.

I did it. Thank you both!