Search

I just created a small extension and wanted to start playing with delegates. Simple task: Adding a script to the head of the admin area when creating a new or editing an old entry of a certain section.

So I created a new folder for my extension with a file called extension.driver.php containing the needed class and the following functions:

    public function getSubscribedDelegates(){
        return array(
                    array(

                        'page' => '/publish/artikel/new',
                        'delegate' => 'InitaliseAdminPageHead',
                        'callback' => 'appendScript'

                    ),
                );
    }

    public function appendScript() {
        die("test");
    }

Nothing happens. I'm sure it's my mistake. Does anybody know what is wrong with this script?

Extension drivers are PHP classes. Are the two methods above from within your class or are these two functions the only thing in your file?

They are in a class, I was just to lazy to copy and paste all the code:

Class extension_adminlayout extends Extension{

    public function about(){
        return array('name' => 'Layout: Adminbereich',
                     'version' => '1.0',
                     'release-date' => '2008-02-03',
                     'author' => array('name' => 'Nils Hörrmann',
                                       'website' => 'http://www.nilshoerrmann.de',
                                       'email' => 'XXX')
                    );
    }

    public function getSubscribedDelegates(){
        return array(
                    array(

                        'page' => '/publish/artikel/new/',
                        'delegate' => 'InitaliseAdminPageHead',
                        'callback' => 'appendScript'

                    ),
                );
    }

    public function appendScript() {
        die("test");
    }       

}

They file itself is in a folder called adminlayout. I see it in the extensions overview and it's enabled.

Sorry, I missed the part where you said you'd created the necessary class and was just focusing on your code.

It could be one of three things:

  1. Try disabling and re-enabling your extension to register the deligate. Each time you modify the delegates in your driver you must disable and re-enable your extension in the admin.
  2. There is a problem with the delicate (i.e. bug).
  3. Alistair has not enabled this part of the extension API yet.

Thanks Lewis for your tips. I wasn't aware of the need to disable/re-enable an extension to get modified delegates working. So I tried it but unfortunately I can't see any change.

I'll think I wait until tomorrow, maybe Alistair can give me a clue then.

Instead of using /publish/artikel/new/ as the page, use /backend/. You will need logic in your class to determine the page, as that delegate is triggered by every page. I am working on something more flexible than just /backend/ but this was the simplest solution for 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