Search

A new Extension, “Configuration Settings” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

This one is not quite ready for prime time, unless all you want to do is be able to view configuration settings from within the Symphony admin. It works well enough for that.

I missed the ability to edit preferences, such as website name, through the Symphony admin, so I wanted to see how far I could get with the development of an extension to restore that sort of functionality, and more. I was able to deconstruct Mark Lewis's Answer Me extension to figure out how to build an administration page for listing the configuration settings. The process has been very useful to learn more about the Configuration and Widget classes.

However, I'm stuck.

I am wondering how to go about adding the inputs and actions for editing the configuration settings. The CSS file contains an instruction to display:none for input elements in a table with a class of selectable. I cannot figure out how to remove the selectable class, or to add a CSS file to override the default behaviour, or to add a style attribute to every input with a value of "display:inline". Then, I need to figure out how to add an action to call the set method of the Configuration class to save the settings.

Any ideas?

Update: GitHub Repository

Get the Configuration Settings Extension from GitHub

I believe you can add a CSS file by adding something like this to your extension.driver.php:

 public function initializeAdmin($context) {

  $page = $context['parent']->Page;

  $page->addStylesheetToHead(URL . '/extensions/configuration/assets/configuration.css', 'screen', 100);

}

... and then adding configuration.css to an assets folder in your extension's directory.

You could also just remove the class via JS. You add the JS like above except replace the CSS line with something like:

       $context['parent']->Page->addScriptToHead(URL . '/extensions/configuration/assets/configuration.js', 220);

Hope that's helpful.

Thanks, czheng. Unfortunately, that didn't work. I searched through the existing extensions to see if any of them had added a CSS file. The method used by the Google Custom Search Engine extension was to use the XMLElement class and the addElementToHead() method of the HTMLPage class:

    $link = new XMLElement('link');
    $link->setAttributeArray(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => URL . '/extensions/configuration/assets/configuration.css'));
    $this->addElementToHead($link, 500);

This solved a couple problems for me. I was able to understand not only how to add a CSS file to one of the views, but also the proper syntax for adding attributes using the Input method of the Widget class (notice the array in the fourth argument passed to the Input method):

    Widget::Input('settings[value]', $setting_value, 'text', array('style' => 'display:inline;')

Now, to figure out how to add an action to the form to set the configuration settings.

Okay, I'm as close as I can get without being able to figure out the last step: how to iterate through the post data to save the data for each setting to the configuration file.

I have a hard-coded set of values in the save function to test the ability to save a single row of data to the $settings array in the config.php file.

    function save() {
        $fields = $_POST['fields'];

        $setting_group = 'admin';
        $setting_name = 'max_upload_size';
        $setting_value = '5242880';

        $this->_Parent->Configuration->set($setting_name, $setting_value, $setting_group);

        return $this->_Parent->saveConfig();
    }

This works well. Anyone else want to take a kick at saving the data for the entire array? I'm still wrapping my head around arrays.

Configuration Settings 1.0

It looks like I've figured it out. Configuration Settings are being saved for the entire array. One problem I had was trying to limit the ability to add new rows to the array in the config file, which happens when modifying the group and setting name values. This will append new settings at the bottom of the file. However, I wasn't able to figure out how to use the TableData function of the Widget class to display a value in plain text along with a hidden input field. I was trying something like this:

            $tableData[] = Widget::TableData($setting_group . Widget::Input('settings[' . $count . '][group]', $setting_group, 'hidden'));

But this would only output the value of the $setting_group variable, and completely ignored the input element. Does anyone know what the proper syntax might be?

One small request: Can you make this so it only shows up for admins? If I log in as an Author it shows up. As a sort of work-around I enable and disable it as I need it but it would be nice not to have to worry about it at all.

I wish I knew how to do that, but I don’t.

Configuration Settings 1.1

http://github.com/bauhouse/configuration/tree/1.1

Change Log

Version 1.1 - 12 August 2009

  • Removed Configuration Overview page.
  • Removed the ability to modify group and name indices of the configuration settings array.
  • Moved Configuration page to System menu.
  • Added the ability to display the current version of Symphony to the “Preferences” page.
  • Added the ability to modify the Site Name on the “Preferences” page.

Version 1.0 - 2 January 2009

  • Initial Release

To Do

  • Author access control

Author access control

AFAIK, you could add

'limit'     => 'developer'

to your array in the fetchNavigation function. This should do the trick (of not showing up for authors).

That works! That was just what I was looking for. Thanks, michael-e.

Configuration Settings 1.2

http://github.com/bauhouse/configuration/tree/1.2

Change Log

Version 1.2 - 12 August 2009

  • Limit access of Configuration Settings page to Developers.

Version 1.1 - 12 August 2009

  • Removed Configuration Overview page.
  • Removed the ability to modify group and name indices of the configuration settings array.
  • Moved Configuration page to System menu.
  • Added the ability to display the current version of Symphony to the “Preferences” page.
  • Added the ability to modify the Site Name on the “Preferences” page.

Version 1.0 - 2 January 2009

  • Initial Release

That works! That was just what I was looking for. Thanks, michael-e.

Cool.

Uh oh, this is pretty frustrating..

This extension just ruined my site by completely breaking the “Root page params” extension. Everything was running well, then after installing this I can’t do root level nav..

See the site, it works with non-root params see here.

I have since uninstalled the extension, but it has broken the site.. How do I fix it?? I can’t roll back, because there was no previous MySQL dump.

Does the Root Page Params extension store its configuration in the Symphony manfiest/config.php? I’m guessing the config file may have become corrupted during saving, which could be a bug in the Configuration Settings extension. Take a look in your config file. Anything amiss?

Update: yes, the Root Page Params stores its values in the maptofront key in the config array. Check the values, perhaps they are now missing or corrupt.

Also, what version of Symphony are you using?

I haven’t updated this extension for a while (August 2009). Surprisingly it seems to have been working okay up until now, based on reports from others (although, I haven’t been using it much myself). I haven’t done a lot of testing with managing configuration settings from other extensions.

Sorry, @into, that the extension ruined your site. Thankfully, there should be no damage your data, since the extension does nothing to the database. Nick is right. The only modifications made by the extension are to the manifest/config.php file. If you have a copy of the settings on a development or staging version, you should be able to copy those settings back into the config file.

I would ask that anyone using this extension be sure to back up configuration settings before using this extension. Plus, it will need to be updated for Symphony 2.2. So user beware. And always back up.

Configuration Settings updated to version 1.3 on 5th of February 2011

@into, I wasn’t able to reproduce the problem you had with the Root page params extension. There was an issue with the alert on saving the preferences when I tested with Symphony 2.2RC1, so I updated the extension. It appears to work fine with configuration settings for other extensions. Please let me know if you still have issues.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details