gpt4 book ai didi

php - 将 HeadScript javascript 与 widmogrod/zf2-assetic-module 和多个模块中的 js 结合起来

转载 作者:行者123 更新时间:2023-12-02 21:52:26 29 4
gpt4 key购买 nike

遇到了一些障碍,我找不到任何支持文档。我的用例相当简单。 Application 模块具有应进入头部的 javascript,而我的其他模块之一 Foo 也具有应进入头部的脚本。我认为这个 Assetic 模块可以解决这个问题。这是我的推断:

应用程序配置

/**
* Assetic
*/
'assetic_configuration' => array(

'buildOnRequest' => true,
'cacheEnabled' => false,
'webPath' => realpath('public/assets'),
'basePath' => 'assets',


'default' => array(

'assets' => array(
'@base_css',
'@head_js',
),

'options' => array(
'mixin' => true,
),
),

'modules' => array(

'application' => array(

# module root path for yout css and js files
'root_path' => __DIR__ . '/../assets',

# collection of assets
'collections' => array(

'base_css' => array(
'assets' => array(
'css/*.css',
),
'filters' => array(),
'options' => array(),
),

'head_js' => array(
'assets' => array(
'js/*.js',
),
'filters' => array(),
),

'base_images' => array(
'assets'=> array(
'images/*.png',
),
'options' => array(
'move_raw' => true,
)
),
),
),
),
),

然后在我的 Foo 模块中...

Foo 模块配置

/**
* Assetic
*/
'assetic_configuration' => array(

'default' => array(
'assets' => array(
'@base_css',
'@head_js',
),

'options' => array(
'mixin' => true,
),
),


'modules' => array(

'foo' => array(

# module root path for yout css and js files
'root_path' => __DIR__ . '/../assets',

# collection of assets
'collections' => array(

'base_css' => array(
'assets' => array(
'css/*.css'
),
'filters' => array(),
'options' => array(),
),

'head_js' => array(
'assets' => array(
'js/*.js' // relative to 'root_path'
),
'filters' => array(),
'options' => array(),
),

'base_images' => array(
'assets'=> array(
'images/*.png'
),
'options' => array(
'move_raw' => true,
)
),
),
),
),
),

不幸的是,通过这个配置,只有 Foo 模块的 javascript 才能进入 head_js.js。我感觉就像米尔顿的那个模因,“我被告知会有 Assets 合并!” :)

感谢您提供的任何帮助。

谢谢!

最佳答案

好的 - 我已经弄清楚了。希望有一天这对其他人有帮助。我上面提到的配置键并非不准确,但是,当考虑到 secret 的未记录功能时,它们的设计不正确;必须破解源代码才能了解到在资源包中包含“head”一词实际上会将其自动加载到头部。最终,这是一个不错的功能,但当您没有意识到时,这确实是一个令人头疼的功能。

关于php - 将 HeadScript javascript 与 widmogrod/zf2-assetic-module 和多个模块中的 js 结合起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18343898/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com