简体   繁体   中英

ZendFramework Headscript Helper - Make scripts unique

How can I ensure that the headScript and headStyle helper include css files only once when added?

The reason I am asking is that I would like to display some contents in a lightbox and all Flashmassages.Eg notifications like profile successfully edited.

To display flashmessages in the lightbox i would like to check at the top of my layout script if they are set, in case they are i would like to attach the required javascript library using the headScript helper.

The problem is that I have no control about the scripts which were already added at this point. Maybe at a page where the library is needed for an other use case, it has already been added with addScript.

How can I ensure all scripts are added only once to my helper?

I already checked that these helpers extend Zend_View_Helper_Placeholder_Container_Standalone which uses an ArrayObject internally to hold the data and provides getters & setter to the array object.

Maybe a solution here would be to check each time when adding a script file if it already exists using the ArrayObject ?

As long as the paths and filenames are the same , the files will only be added once. The Zend View Helpers should take care of that for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM