appending attributes to script in head using addScriptToHead?
This is an open discussion with 2 replies, filed under Extensions.
Search
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.
I'm looking at the DropBox chooser developer API as a method to link DropBox files to sections and the JS looks like this:
Is it possible to add the attribute to the scriptHead function as well? I can't find the docs that relate to this!