Drupal 模块主题 - 默认 CSS?

发布于 2024-09-06 10:52:51 字数 106 浏览 1 评论 0原文

有大量关于如何覆盖 Drupal 模块外观的文档,但我一直发现编写原始主题的文档有点缺乏。关于这一点,我如何告诉 Drupal 使用特定的 CSS 文件作为我的自定义模块的块输出?

There's tons of documentation out there on how to override the appearance of Drupal modules, but I keep finding the docs for writing the original theme to be a little lacking. On this note, how can I tell Drupal to use a specific CSS file for my custom module's block output?

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

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

发布评论

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

评论(2

初心未许 2024-09-13 10:52:51

您可以使用 drupal_add_css 在模块代码(而不是主题)中为模块添加自定义 css。 admin_menu 模块中 hook_init 的示例:

$path = drupal_get_path('module', 'admin_menu');
drupal_add_css($path .'/admin_menu.css', 'module', 'all', FALSE);

如果您只想在主题级别自​​定义 css,请在主题的 .info 文件中添加对 css 路径的引用。

You can add a custom css for your module, in your module code (rather than the theme), by using drupal_add_css. Example from hook_init in admin_menu module:

$path = drupal_get_path('module', 'admin_menu');
drupal_add_css($path .'/admin_menu.css', 'module', 'all', FALSE);

If you just want custom css at the theme level, then add a reference to the css path in your theme's .info file.

奢华的一滴泪 2024-09-13 10:52:51

对于块,您可能会在块类模块中找到很好的用途。

http://drupal.org/project/block_class

如果你的模块正在输出一个块,它应该有来自 block.tpl.php 输出的 ID,它是覆盖的主要内容。您还可以从模块中分配一个类或 ID 方案,这也将有助于主题化。

For blocks, you may find good use in the block class module.

http://drupal.org/project/block_class

If your module is outputting a block, it should have an ID from block.tpl.php output which is prime for overriding. You can also assign a class or ID scheme from your module which will also assist in theming.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文