Search

Can You write some short explanation or pseudo-code for defining own page in administration area? I was looking into the code of Symphony, but i'm still not sure where to define path and page data. I know there is class.extension->fetchNavigation() function, but i'm not sure how to define callback which generates page.

It is fairly easy actually. Create a folder in your extension called content and add files that match the format content.XXX.php where XXX is the name of the page. You can then access the page via /symphony/extension/YOUREXTENSION/XXX/. By default, if you do not include XXX is will assume index. Have a look at one of the following code as a basis for adding your own pages:

require_once(TOOLKIT . '/class.administrationpage.php');

Class contentExtensionMyExtensionPreferences extends AdministrationPage{

    private $_driver;

    function __construct(&$parent){
        parent::__construct($parent);

        $this->setTitle('Symphony – My Extension – Preferences');
        $this->setPageType('form');

        $this->_driver = $this->_Parent->ExtensionManager->create('myextension');

    }

    function view(){

        $this->appendSubheading('Preferences');

        ## Add stuff here

        $div = new XMLElement('div');
        $div->setAttribute('class', 'actions');

        $attr = array('accesskey' => 's');
        $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', $attr));

        $this->Form->appendChild($div); 

    }

    function action(){

    }   
}

To get something into the navigation you need to implement a function in the Extension driver class. here is an example that added a new navigation group with 2 child links:

    public function fetchNavigation(){
        return array(
            array(
                'location' => 330,
                'name' => 'My Extension',
                'children' => array(
                    array(
                        'name' => 'Browse',
                        'link' => '/browse/'
                    ),

                    array(
                        'name' => 'Preferences',
                        'link' => '/preferences/'
                    ),                      
                )
            )

        );
    }

Notice the location attribute. That tells Symphony where position the new group and is relative to the existing Navigation groups. You can see the positions by looking at /symphony/assets/navigation.xml. If you would like to put a link into an existing group, omit the you can do the following:

    public function fetchNavigation(){
        return array(
            array(
                'location' => 200,
                'name' => 'My Extension',
                'link' => '/preferences/'               
            )

        );
    }

That would put a link into the Blueprint group. Note that by adding additional arrays to the function you can add more links and groups.

Let me know if that helps.

Yes, it helped me A LOT! Thanks! :).

You could use this explanation in documentation. I just didn't notice at first that class name and path to page are required to be the same (so if path is like: symphony/extension/myextension/list then class should be named like: contentExtensionMyExtensionList and value of navigation link should be '/list/').

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