Search

I’m building an extension and I’m trying to do a quite simple thing: I’d like to insert a script to the backend pages when the user browses /blueprints/sections/.

I know how to always append the script:

    public function getSubscribedDelegates(){
        return array(
            array(
                'page' => '/administration/',
                'delegate' => 'AdminPagePreGenerate',
                'callback' => '__appendAssets'
            )
        );
    }

    public function __appendAssets($context) {
            Administration::instance()->Page->addScriptToHead(URL . '/extensions/mediathek/assets/section.js', 100);
    }

But how do I add a check for the currently browsed backend page? If I simple print $context I find something called pageroot which contains everything I need, but I don’t know how to access it.

Any tips or ideas?

I had the same problem — $context in this instance is an object with mostly private members which cannot be accessed.

You can however inspect the type of Administration::instance()->Page like so:

if (Administration::instance()->Page instanceof contentBlueprintsSections) {
    var_dump(Administration::instance()->Page->_context);
}

The use of the static Administration instance (and Frontend instance for front end pages) means the $context is mostly redundant in this instance. Of course, context elsewhere receives things such as arrays and IDs which can’t be gleaned from the parent instance.

Nick, that’s a great tip - thank you!

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