Search

Hi,

I have a section with a checkbox where, depending on whether it is checked or not, two textboxes are displayed or not. This is easily done by a little extension which adds a .js file to Backend in a getSubscribedDelegates function (the script uses jQuery to do the job). My getSubscribedDelegates looks like this:

        public function getSubscribedDelegates() {
        return array(
            array(
                'page'      => '/backend/',
                'delegate'  => 'InitaliseAdminPageHead',
                'callback'  => 'addJSHeaders'
            )
        );
    }

It adds my .js to all backend pages. I want to add it only to two pages, /publish/mysection/edit and /publish/mysection/new.

This wouldn’t be a problem if a HTML code of backend page had a field with information of what page I am visiting. There is no such a thing, so here is my question ;)

Hi,

I have done similar using Nick’s HTML Panel field.

Using this field, I added a script tag to the document. The HTML Field will be visible, and empty, but you can can hide it using the script your are adding script.

Ross

rc1, maybe that does the trick, but it is far to complex for a simple problem ;)

Nils, this code works but it adds a script to all edit/new pages. I want to add my .js only to edit/new of one specific section.

Also, I want to remove “Create new” and “Delete” buttons in this section.

How about this?

You just have to add another check for the section name which should be present in $callback['context'] as well.

Yay, there is a $callback[‘context’][‘section_handle’], which is of course a section handle.

Thanks a lot!

@rudy: true. however there are advantages to this technique: the section name need not be hard-coded in PHP & the modifications (js) are visible to other developers from the Section’s edit page.

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