Zend追加文件调整

发布于 2024-12-25 12:41:47 字数 194 浏览 4 评论 0原文

如何多次包含相同的 .js 文件,但它只会将其添加到标头一次。这个想法类似于 PHP 中的 include 和 include_once 函数。我正在使用以下 zend 框架函数。和想法将不胜感激。

appendFile($src, $type = 'text/javascript', $attrs = array())

How can I include a same .js file multiple times but it will add it to the header only once. The idea is similar to include and include_once function in PHP. I am using the following zend framework function. And idea would be appreciated.

appendFile($src, $type = 'text/javascript', $attrs = array())

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心不设防 2025-01-01 12:41:47

有两种可能性:

  1. 扩展 Zend_View_Helper_HeadScript 并循环遍历容器 ($view->headScript()->getContainer()) 以检查文件是否已存在
  2. 在渲染 headScript() 之前,检索容器并过滤掉重复项。

There are two possibilities:

  1. Extend Zend_View_Helper_HeadScript and loop through the container ($view->headScript()->getContainer()) to check whether the file already exists
  2. Before rendering the headScript(), retrieve the container and filter out duplicates.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文