【问题标题】:How to include Drupal 7 properties in a .info.yml file for Drupal 8?如何在 Drupal 8 的 .info.yml 文件中包含 Drupal 7 属性?
【发布时间】:2019-11-14 17:04:06
【问题描述】:

我正在将 Drupal 7 主题移植到 Drupal 8(这是迁移整个网站的一部分)。我知道第一步是创建目录结构并修改.info文件。但是,我被困在几个地方。

我之前的.info 文件具有以下属性:

name: Theme
type: theme
description: 'My custom theme'
core: 8.x
engine: twig
screenshot: screenshot.png
base theme: omega

regions:
    page_top: 
    page_bottom:
    content:
    other stuff:

zones:
    user:
    branding:
    header:
    preface:
    content:
    postscript:
    footer:

css:
    global.css:
        name:
        description:
        options:
            weight:

stylesheets:
    all:
        -some css files from my cs folder

scripts:
    -some scripts from my js folder

grids:
    theme_default:
        name:
        layouts:
            wide:
            normal:
            narrow:
        columns:
            full:
            24:
            16:
            12:

settings:
    a ton of settings:

version: "8.x"
core: "8.x"
project: "omega"

但是,我发现并非所有这些都是有效的密钥(如 https://www.drupal.org/docs/8/theming-drupal-8/defining-a-theme-with-an-infoyml-file 所示)。我知道stylesheetsscripts 属性现在由库处理,但仍然留下zonescssgridssettings 属性。我应该让它们保持原样,还是有特殊的方法来处理它们?

【问题讨论】:

    标签: drupal drupal-8


    【解决方案1】:

    Drupal 8 theme info file documentation 中定义的主题信息文件中支持的键名是

    name (required)
    type (required)
    description (optional)
    package (optional)
    core (required)
    php (optional)
    version (optional)
    libraries (optional)
    libraries-override (optional)
    libraries-extend (optional)
    base theme (recommended)
    hidden (optional)
    engine (optional)
    logo (optional)
    screenshot (optional)
    regions (optional)
    regions_hidden (optional)
    features (optional)
    stylesheets-remove (deprecated)
    ckeditor_stylesheets (optional)
    

    所以你的主题信息文件只能有这些属性。其他任何内容都将被忽略。

    但是,drupal 8 允许主题和模块具有任意数量的自定义配置,这些配置可以通过配置模式系统加载。您可以使用它定义所有其他设置。您可以从以下内容中了解更多信息

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-15
    • 1970-01-01
    • 2015-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多