Documentation

Configuration

Download (pdf)

Overview

The framework allows the use of parameters stored in each component.

Defining Options

Configuration options can also be defined in a separate file named config.xml located in the /config sub-directory of the component directory.

/app
.. /components
.. .. /com_hello
.. .. .. /config
.. .. .. .. config.xml

The XML file's root element should be <config>. Fields are then added and grouped by fieldsets. These fieldsets correspond to the tabs located in the admin side when viewing the component's options.

<?xml version="1.0" encoding="utf-8"?>
<config>
	<fieldset
		name="greetings"
		label="COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_LABEL"
		description="COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_DESC"
	>
		<field
			name="greeting"
			type="text"
			label="COM_HELLOWORLD_FIELD_GREETING_LABEL"
			description="COM_HELLOWORLD_FIELD_GREETING_DESC"
			default=""
		/>
	</fieldset>
</config>

It is good practice to use the component's language file to define all the appropriate strings.

Retrieving Values

One may quickly retrieve the options for any component by calling the params() method on the Component facade or directly accessing the method on the underlying Hubzero\Component\Loader class. This method returns a Hubzero\Config\Registry object.

$params = Component::params('com_hello');

echo $param->get('greeting');

Last modified: