微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我可以使用依赖模块 drupal 中的 css/js 吗?

如何解决我可以使用依赖模块 drupal 中的 css/js 吗?

我在 Drupal 7 上有两个模块。我想让依赖模块从其他模块加载 css/js 文件

父模块信息:

name = mymodule
description = ParentModule
core = 7.x
version = «7.x-1.0»
configure = admin/config/content/mymodule
files[] = mymodule.module
scripts[] = mymodule.js
stylesheets[all][] = css/main.css
stylesheets[all][] = css/mobile.css

依赖模块信息:

name = mysecondmodule
description = DependentModule
dependencies[] = mymodule ; here I inject dependences
core = 7.x
version = «7.x-1.0»
configure = admin/config/content/mysecondmodule

主模块是依赖的。所有我想要的,创建“父”模块,它将只包含可以从我的主模块和其他模块加载的 css 文件(没有其他任何东西)。我知道最好的方法主题,但我需要它。

解决方法

正如我所见,Drupal 显示 mysecondmodule 是依赖的。因此,如果没有 mymodule,则会有相关通知。 因此,在依赖模块信息中,我们可以添加以下内容:

name = mysecondmodule
description = DependentModule
dependencies[] = mymodule ; here I inject dependences
core = 7.x
version = «7.x-1.0»
configure = admin/config/content/mysecondmodule
stylesheets[all][] = ../mymodule/css/main.css   ; relative path to "parent" module
stylesheets[all][] = ../mymodule/css/mobile.css ;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。