【发布时间】:2016-03-10 16:20:04
【问题描述】:
我创建了我的自定义模块(contact_form),但我不知道如何为这个表单设置主题?如何创建模板或如何在我的表单中添加 CSS? 我有我的 CSS 和 JS。
【问题讨论】:
标签: drupal-theming drupal-8 drupal-forms
我创建了我的自定义模块(contact_form),但我不知道如何为这个表单设置主题?如何创建模板或如何在我的表单中添加 CSS? 我有我的 CSS 和 JS。
【问题讨论】:
标签: drupal-theming drupal-8 drupal-forms
您可以查看 drupal.com 文档吗:https://www.drupal.org/developing/api/8/assets
加载资产 (CSS/JS) 的一般步骤是:
1. Save the CSS or JS to a file. 2. Define a "library", which can contain both CSS and JS files. 3. "Attach" the library to a render array in a hook.但是在主题的情况下,还有第 3 步的替代方案:主题 可以选择在所有页面上加载任意数量的资产库。
检查这个 stackoverflow 答案:https://stackoverflow.com/a/37723273/1153703
你也可以查看我在这里找到的服装主题示例:http://wiki.workassis.com/drupal-8-custom-theme-from-scratch/
【讨论】: