Creating the Component Config
Let's start creating buttons for clicking into the config page by page to build a list of data. In the examples use the Component Name com_helloworld.
Open the folder into the folder views hellos edit the file view.html.php.
com_helloworld/views/hellos/view.html.php
function addToolbar()
{
JToolbarHelper::title(JText::_('COM_HELLOWORLD_HELLO_HELLO_LIST'));
JToolbarHelper::addNew('add');
JToolbarHelper::editList('edit');
JToolbarHelper::deleteList('Are you sure?', 'delete');
JToolbarHelper::preferences('com_helloworld'); // สร้างปุ่มสำหรับเข้าสู่หน้า config
JHtmlSidebar::setAction('index.php?option=com_content&view=articles');
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_PUBLISHED'),
'filter_published',
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)
);
}
Next, create a config.xml file in the folder com_helloworld. It uses a similar structure to create XML Form.
com_helloworld/config.xml
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset
name="setting"
label="Setting">
<field
name="date_format"
type="text"
label="Date Format"
/>
</fieldset>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
class="inputbox"
validate="rules"
filter="rules"
component="com_content"
section="component" />
</fieldset>
</config>
For the values defined in the config used.
$config = JComponentHelper::getParams('com_helloworld');
echo $config->get('date_format')