Configuration
Everything in Sympal was designed to be as configurable as possible. This
is why the sfSympalConfig class was introduced. It is an extension of
sfConfig made specifically for Sympal.
The configuration values are organized in to groups so that groups of configurations can be specified. This is useful if a Sympal plugin introduces several new configurations then they will be all in one group and won't be all grouped together.
Manipulating
You can easily manipulate the Sympal configuration by using the sfSympalConfig
class.
Setting
Setting Sympal configuration values is the same as sfConfig.
<?php echo sfSympalConfig::set('rows_per_page', 20); ?>
Getting
Getting Sympal configuration values is also the same as sfConfig:
<?php echo sfSympalConfig::get('rows_per_page'); ?>
Writing
You can write new settings to disk by using the writeSetting method.
The arguments for this method are the same as the set method the only
difference is that the value is set in memory but it is also written to
disk so that it is remembered.
<?php sfSympalConfig::writeSetting('installed', true); ?>
Groups
Sympal configuration can be organized in to groups. Up until now we've only worked with root level configurations but now we'll show you how to set and get values from a group.
<?php sfSympalConfig::set('new_group', 'name', 'value'); ?>
Default Values
You can also specify default values in the same way you do for sfConfig.
<?php sfSympalConfig::get('new_group', 'name', 'default_value'); ?>
Configuration Files
All of the values for sfSympalConfig can have default values specified
by the app.yml. If you are already familiar with Symfony then you should
know what this is. The app.yml is where all project specific configuration
can be stored and accessed from sfConfig. All of the Sympal configuration
values are stored under the key named sympal_settings. Below is an example
where we change some of the default values set by Sympal in our
config/app.yml file:
---
all:
sympal_config:
# Disable markdown editor
enable_markdown_editor: false
# Disable elastic textareas
elastic_textareas: false
# Enable page caching with the layout
page_cache:
enabled: true
with_layout: true
lifetime: 3600
Web Editable Configuration
Some of these configuration values are things that can be changed and modified after Sympal has been installed. In the case of these values you may want to allow them to be edited from within Sympal in your browser.
If you login to Sympal as an administrator and browse to Administrator > Configuration, you will see a form that lets you edit certain configuration values.

This form is dynamically built through the firing of an event named
sympal.load_config_form. You can connect to this event from anywhere and
add new editable configurations to the form. Below is an example.
<?php $dispatcher->connect('sympal.load_config_form', array($this, 'loadConfig')); public function loadConfig(sfEvent $event) { $form = $event->getSubject(); $form->addSetting('some_group', 'enabled', 'Some Enabled Config', 'InputCheckbox', 'Boolean'); $form->addSetting(null, 'no_group', 'No Group Config'); } ?>
The arguments for addSetting are as follows:
- $groupName - The group name the configuration is under. If none, specify null.
- $configName - The name of the configuration value.
- $configLabel - The label of the configuration value for the form.
- $widget - The name or instance of the widget to edit the value.
- $validator - The name or instance of the validator to validate the value.
If you do not specify a widget or validator it defaults to
sfWidgetFormInputandsfValidatorString.



