# Introducing Module Helpers

The module helper is an easy way to access module related information, such as configurations, handlers and more. Using the module helper can simplify your code.

## Simplify Reading Module Configs

Consider the common task of getting a configuration value for a module. This can get more complicated if you need this in a circumstance where your module is not the currently active module.

Here is an example of how this is done now. We have a module named “bar” and we want to get the configuration “foo”:

```php
$module_handler = xoops_gethandler('module');
$module         = $module_handler->getByDirname('bar');
$config_handler = xoops_gethandler('config');
$moduleConfig   = $config_handler->getConfigsByCat(0, $module->getVar('mid'));
$value = (isset($moduleConfig['foo']) ? $moduleConfig['foo'] : 'baz';
echo "The value of 'foo' being used is: " . $value;
```

Here is an XMF version that accomplishes the same thing:

```php
$helper = \Xmf\Module\Helper::getHelper('bar');
echo "The value of 'foo' being used is: " . $helper->getConfig('foo', 'baz');
```

## Easy Access to Module Object

Here, we extend the last example to get the module's version using our XMF module helper.

```php
$version = $helper->getModule()->getVar('version');
```

See the reference section for [Xmf\Module\Helper](/xmf-cookbook/reference/module/helper.md) for more about the module helper.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xoops.gitbook.io/xmf-cookbook/recipes/introducing-module-helpers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
