【问题标题】:Prestashop Child ThemePrestashop 儿童主题
【发布时间】:2018-10-24 15:20:27
【问题描述】:

我为我购买的主题创建了 Prestashop 子主题。 我可以看到我的子主题(一旦启用),但每次我访问主题页面切换主题时都会收到 500 错误。

我解决这个问题的方法是更改​​我的子主题的 config/theme.yml 文件。这是我通常拥有的,这给了我 500 错误:

parent: parent-theme
name: My Child Theme
display_name: Child Theme
version: 1.0.0
author:
  name: "Me"
  email: "email@email.com"
  url: "domain.com"

assets:
  use_parent_assets: true
  css:
    all:
      - id: theme-custom
      path: assets/css/custom.css
      media: all
      priority: 1000
  js:
    all:
      - id: theme-custom
        path: assets/js/custom.js
        priority: 1000
        position: bottom

这是我需要在 confog/theme.yml 文件中包含的内容,以免出现 500 错误:

parent: parent-theme
name: My Child Theme
display_name: Child Theme
version: 1.0.0
author:
  name: "Me"
  email: "email@email.com"
  url: "domain.com"

assets:
  use_parent_assets: true

以 css: 开头的行是什么导致了这个问题? – id: 是否需要引用它上面的东西,还是必须是 theme-custom

你们有什么好的教程/参考可以指点我,以正确的方式创建子主题吗?

我的 Prestashop 版本是 1.7.3

谢谢。

【问题讨论】:

  • 这是来自 PS 的最新文档:devdocs.prestashop.com/1.7/themes/reference/…
  • 我看到了文档...我很困惑,所以没有必要包含对孩子的 css 和 js 文件的引用——“use_parent_assets: true”行下面的所有内容?
  • 没错,不需要,通过指定use_parent_assets: true 表示您将使用父主题中的资产。这是 PrestaShop 记录的第一个示例,更简单:build.prestashop.com/news/Child-Themes-Feature
  • 好的,但是如果我想在我的子主题中使用我自己的 css 来进行我自己的更改,我该怎么办? JS 文件也一样...
  • 正如您在帖子中所做并指出的那样,我将给出答案以打印代码示例。

标签: themes prestashop child-theming


【解决方案1】:

您可以阅读完整指南如何实现这一点:https://devdocs.prestashop.com/1.7/themes/reference/template-inheritance/parent-child-feature/

但是您需要在 theme.yml 文件中使用您的自定义样式/脚本文件的代码,这里是一个完整的示例。

parent: classic
name: childtheme
display_name: My first child Theme
version: 1.0.0
assets:
 use_parent_assets: true
 css:
   all:
     - id: custom-lib-style
       path: assets/css/custom-lib.css
 js:
   all:
     - id: custom-lib-script
       path: assets/js/custom-lib.js

PD。保持正确的表格很重要,否则无法正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-06
    • 2013-12-03
    • 2018-04-20
    • 2017-06-06
    相关资源
    最近更新 更多