Jump to content

Using config data for the module elsewhere


gornycreative
 Share

Recommended Posts

Hi,

I'm trying to wrap my head around configurable modules. The issue I am running into is that I'm not sure when or how to get the configured values to be used for other backend processes.

At first, the config saved but nothing on the backend in terms of methods was using those value.

Now when values change, the backend methods pick up the changed values to the config and uses those in my method calls, but if a value didn't change it doesn't get brought in to my public vars.

The structure I have in place (roughly) is:\

class ClassName extends WireData implements Module, ConfigurableModule {

	getModuleInfo() {

	}

	public var declarations

	public function ready() {

		$mod_config = modules()->getConfig('ClassName')

		//I have code here that assigns values from the $mod_config array to my public vars if values exist

		

	}

	public function getModuleConfigImputfields() {

		//Here I've got my fields set up properly and the config saves fine and values load fine from the DB.

	}

}

Is there something else I need to do to utilize those values?

Link to comment
Share on other sites

Config variables should be available as properties of the module if I'm not missing anything. So if you add a config inputfield with the name 'foo' it should be available as $this->foo. Or from outside the module it should be available as $modules->get('YourModule')->foo;

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...