The Joomla framework allows the use of parameters stored in each component. The fields for the configuration options are stored in the XML file located at admin/config.xml. 

This file is read by the com_config component of the Joomla core.

<?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="show_category"
type="radio"
label="COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_LABEL"
description="COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_DESC"
default="0"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
</config>

Additionally, you need to put Preferences (Options) button in a toolbar.

JToolBarHelper::preferences('com_helloworld');

How To Get Configuration Values 

You need to get a component params for use at different places in the code. To access component params in component itself, you can use JFactory::getApplication() like below:

$app = JFactory::getApplication();
$params = $app->getParams();
$param = $params->get('show_category');

To access component params from another component, you can use JComponentHelper::getParams() like below:

$content_params = JComponentHelper::getParams( 'com_content' );
$show_date = $content_params->get( 'show_create_date' );

Default Configuration, Item Configuration, Menu Configuration

In Joomla, configuration parameters for extensions can be set at many levels.

1. The default configuration is stored in admin/config.xml file at the administrator part of the component.

2. At the menu level, it is stored in default.xml file in the tmpl folder of front-end view.

3. Administrator can control the display in the front end by specifying a global configuration parameter or override this setting on an individual item basis. To enable this, you need a params field in the database, which will be a string in JSON format.

Step 1: Change XML form for item to add params field

You need to edit configuration parameters for each item, so you need to change the XML form.

admin/models/forms/helloworld.xml

<fields name="params">
<fieldset name="params" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
<field
name="show_category"
type="list"
label="Show Category"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
</fields>

Step 2: Modify table class to handle JSON string

The following function will convert params field to JSON string. You have to overload the bind method to convert the array of the parameters into a JSON string for saving in the database.

admin/tables/helloworld.php

public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
// Convert the params field to a string.
$parameter = new JRegistry;
$parameter->loadArray($array['params']);
$array['params'] = (string)$parameter;
}

return parent::bind($array, $ignore);
}

Step 3: Modify back-end edit layout

The backend edit view has to display the options to the administrator.

admin/views/helloworld/tmpl/edit.php

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'options', 'Options'); ?>
<div class="row-fluid form-horizontal-desktop">
<?php echo $this->form->renderFieldset('params'); ?>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>

Step 4: Modify front end model to merge global parameters and individual parameters

The parameters are stored at two levels - global parameters and individual parameters. First, the global parameters are stored in the state variable in the function populateState(). 

site/models/helloworld.php

protected function populateState()
{
// Get the message id
$jinput = JFactory::getApplication()->input;
$id = $jinput->get('id', 1, 'INT');
$this->setState('message.id', $id);

// Load the parameters.
$this->setState('params', JFactory::getApplication()->getParams());
parent::populateState();
}

Then, we get the stored params from the database in the getItem() as a JSON string. After that, load the JSON string as array and merge global params with item params.

public function getItem()
{
if (!isset($this->item))
{
$id = $this->getState('message.id');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('h.greeting, h.params, c.title as category')
->from('#__helloworld as h')
->leftJoin('#__categories as c ON h.catid=c.id')
->where('h.id=' . (int)$id);
$db->setQuery((string)$query);

if ($this->item = $db->loadObject())
{
// Load the JSON string
$params = new JRegistry;
$params->loadString($this->item->params, 'JSON');
$this->item->params = $params;

// Merge global params with item params
$params = clone $this->getState('params');
$params->merge($this->item->params);
$this->item->params = $params;
}
}
return $this->item;
}