gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 04:53:53 25 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。我感觉就像里面有 Milton 的模因,“有人告诉我会有 Assets 合并!” :)

如果您能提供任何帮助,我们将不胜感激。

谢谢!

最佳答案

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

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

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