Search

I'm looking at the DropBox chooser developer API as a method to link DropBox files to sections and the JS looks like this:

<script type="text/javascript" src="https://www.dropbox.com/static/api/1/dropbox.js" id="dropboxjs" data-app-key="app_key"></script>

Is it possible to add the attribute to the scriptHead function as well? I can't find the docs that relate to this!

I didn't find anything in the documentation either, but here's the source in whatever Symphony I have checked out:

    /**
     * Convenience function to add a `<script>` element to the `$this->_head`. By default
     * the function will allow duplicates to be added to the `$this->_head`. A duplicate
     * is determined by if the `$path` is unique.
     *
     * @param string $path
     *  The path to the script file
     * @param integer $position
     *  The desired position that the resulting XMLElement will be placed
     *  in the `$this->_head`. Defaults to null which will append to the end.
     * @param boolean $duplicate
     *  When set to false the function will only add the script if it doesn't
     *  already exist. Defaults to true which allows duplicates.
     * @return integer
     *  Returns the position that the script has been set in the `$this->_head`
     */
    public function addScriptToHead($path, $position = null, $duplicate = true){
        if($duplicate === true || ($duplicate === false && $this->checkElementsInHead($path, 'src') === false)){
            $script = new XMLElement('script');
            $script->setSelfClosingTag(false);
            $script->setAttributeArray(array('type' => 'text/javascript', 'src' => $path));

            return $this->addElementToHead($script, $position);
        }
    }

So it looks like you'd have to extend the HTMLpage class and override the addScriptToHead method, adding to the line that deals with attributes. Or skip the method and do it in a more manual/one-off way?

Thanks for looking David.. I've added what I needed in the displaypublishpanel function for now as it is a field related call to a js file.. but I think it may be worth adding params for $attributes into the core function would really help.

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