Search

A new Extension, “Site Name” 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.

I figured if I could save an array of configuration settings to the config.php file, then saving a single configuration setting shouldn't be a problem. I was using the extensions provided with a default install of Symphony 2.0: Maintenance Mode and Export extensions as examples of how to extend the System Preferences page.

The challenges arose when trying to figure out how delegates work. Also, the Maintenance Mode extension passed a $context array from one function to another. I couldn't figure out what this array was for.

This is probably not the correct way to accomplish this, but it works. However, I have no idea how to append alerts to the page.

    class extension_sitename extends Extension {

        public function about() {
            return array(
                'name'          => 'Site Name',
                'version'       => '1.0',
                'release-date'  => '2009-01-02',
                'author'        => array(
                    'name'          => 'Stephen Bau',
                    'website'       => 'http://www.domain7.com/',
                    'email'         => 'stephen@domain7.com'
                ),
                'description'   => 'Symphony System Preference for modifying the site name'
            );
        }

        public function getSubscribedDelegates(){
            return array(
                array(
                    'page' => '/system/preferences/',
                    'delegate' => 'AddCustomPreferenceFieldsets',
                    'callback' => 'appendPreferences'
                ),

                array(
                    'page' => '/system/preferences/',
                    'delegate' => 'Save',
                    'callback' => '__SavePreferences'
                ),

                array(
                    'page' => '/backend/',
                    'delegate' => 'AppendPageAlert',
                    'callback' => '__AppendAlert'
                ),
            );
        }

        public function __SavePreferences(){
            $settings = $_POST['settings'];

            $setting_group = 'general';
            $setting_name = 'sitename';
            $setting_value = $settings['general']['sitename'];

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

    //  redirect(URL . '/symphony/system/preferences/?action=sitename-saved');

        }

        public function __AppendAlert($context){
            if($_REQUEST['action'] == 'sitename-saved'){
                $this->_Parent->Page->pageAlert('The site name was updated successfully.', AdministrationPage::PAGE_ALERT_NOTICE);
            }
        }

        public function appendPreferences($context){
            $group = new XMLElement('fieldset');
            $group->setAttribute('class', 'settings');
            $group->appendChild(new XMLElement('legend', 'Site Name'));         

            $sitename = $this->_Parent->Configuration->get('sitename', 'general');
            $label = new XMLElement('label', 'Website Name');           
            $label->appendChild(Widget::Input('settings[general][sitename]', $sitename, 'text'));

            $group->appendChild($label);                        
            $context['wrapper']->appendChild($group);
        }
    }

Thanks for this. It's better than modifying the config as a super user.

@huyaroo, you're welcome. Thanks for reminding me. I had forgotten I had created this extension.

GitHub Repository

Now available from GitHub.

Site Name updated to version 1.1 on 11th of February 2011

Thanks for the useful extension. The extension page says unsure for 2.2.1 compatibility. That should be changed to compatible. I just tested it on a fresh 2.2.1 install. The form shows up in Preferences and changing the name works as expected: the name at the top of the admin pages, the name in the extension form, and the name in the generated XML for the front-end of the website all reflect the change =)

@megamanXplosion, thanks for testing out the extension. I've updated the extension page to indicate compatibility with Symphony 2.2.1. :-)

Hey @bauhouse, using this extension on a site build and wondering about apostrophes etc.. Does it handle these on output? or do I need to escape the entities beforehand?

Site Name updated to version 1.2 on 5th of November 2011

@moonoo2, I believe the extension is properly handling site names with special characters now.

They were being properly escaped when saved to the configuration file, but they weren't being properly formatted when reading the value and populating the Site Name preferences field. This should be fixed now.

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