$modules->isConfigurable() method

Is the given module configurable?

This method can be used to simply determine if a module is configurable (yes or no), or more specifically how it is configurable.

Return value details

If module is configurable via external configuration file:

  • Returns string of full path/filename to ModuleName.config.php file

If module is configurable because it implements a configurable module interface:

  • Returns boolean true if module is configurable via the static getModuleConfigInputfields() method. This particular method is compatible with all past versions of ProcessWire.
  • Returns integer 2 if module is configurable via the non-static getModuleConfigInputfields() and requires no arguments.
  • Returns integer 3 if module is configurable via the non-static getModuleConfigInputfields() and requires $data array.
  • Returns integer 4 if module is configurable via the non-static getModuleConfigInputfields() and requires InputfieldWrapper argument.
  • Returns integer 19 if module is configurable via non-static getModuleConfigArray() method.
  • Returns integer 20 if module is configurable via static getModuleConfigArray() method.

If module is not configurable:

  • Returns boolean false if not configurable

This method is named isConfigurableModule() in ProcessWire versions prior to to 3.0.16.

Available since version 3.0.16.

Examples

// Determine IF a module is configurable
if($modules->isConfigurable('HelloWorld')) {
  // Module is configurable
} else {
  // Module is NOT configurable
}
// Determine HOW a module is configurable
$configurable = $module->isConfigurable('HelloWorld');
if($configurable === true) {
  // configurable in a way compatible with all past versions of ProcessWire
} else if(is_string($configurable)) {
  // configurable via an external configuration file
  // file is identifed in $configurable variable
} else if(is_int($configurable)) {
  // configurable via a method in the class
  // the $configurable variable contains a number with specifics
} else {
  // module is NOT configurable
}

Usage

// basic usage
$bool = $modules->isConfigurable($class);

// usage with all arguments
$bool = $modules->isConfigurable($class, bool $useCache = true);

Arguments

NameType(s)Description
classModule, string

Module name

useCache (optional)bool

Use caching? This accepts a few options:

  • Specify boolean true to allow use of cache when available (default behavior).
  • Specify boolean false to disable retrieval of this property from getModuleInfo (forces a new check).
  • Specify string interface to check only if module implements ConfigurableModule interface.
  • Specify string file to check only if module has a separate configuration class/file.

Return value

bool string int

See details about return values in method description.


$modules methods and properties

API reference based on ProcessWire core version 3.0.137

Twitter updates

  • ProcessWire 3.0.144 and 3.0.145 add improved field template context override settings and include a new Inputfields API, along with numerous other issue fixes, optimizations and improvements to the core. More
    8 November 2019
  • ProcessWire 3.0.144 core updates: Upgraded overrides section in the field editor, a new Inputfields JS API, and more— More
    1 November 2019
  • ProcessWire 3.0.143 core updates — 26 commits and 18 resolved issue reports, plus some other useful improvements and additions. More here: More
    25 October 2019

Latest news

  • ProcessWire Weekly #288
    In the 288th issue of ProcessWire Weekly we'll cover the latest core updates, introduce WireMailSendGrid, host a new weekly poll, and showcase a new site of the week. Read on!
    Weekly.pw / 16 November 2019
  • ProcessWire 3.0.145 core updates
    ProcessWire 3.0.144 and 3.0.145 add improved field template context override settings and include a new Inputfields API, along with numerous other issue fixes, optimizations and improvements to the core.
    Blog / 8 November 2019
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits