Magento 2-主题类型0:物理,1:虚拟,2:舞台。什么时候使用?


30

theme表中的type字段包含3个可能的值:物理,虚拟和分段。

何时使用物理虚拟和暂存主题?

当我扩展亮度主题时,我的新主题将以虚拟类型出现在主题表中。但是看起来这种类型不允许覆盖某些文件,并且仅将主题类型从虚拟更改为物理允许我扩展示例Magento_Theme包。


好问题可能不知道0: Physical - Magento Default Theme (Example: Magento Blank, Magento Luma, Magento 2 Backend) 1: Virtual - Custom Theme which is created by you (custom) which has parent as Default Theme (Example: My Theme) 2: Staging - ?
ANKIT沙阿

请参阅vendor\magento\module-theme\Model\Theme\Registration.php /** Allowed sequence relation by type, array(parent theme, child theme) * @var array */ protected $_allowedRelations = [ [ThemeInterface::TYPE_PHYSICAL, ThemeInterface::TYPE_VIRTUAL], [ThemeInterface::TYPE_VIRTUAL, ThemeInterface::TYPE_STAGING],]; /** Forbidden sequence relation by type ** @var array*/ protected $_forbiddenRelations = [[ThemeInterface::TYPE_VIRTUAL, ThemeInterface::TYPE_VIRTUAL],[ThemeInterface::TYPE_PHYSICAL, ThemeInterface::TYPE_STAGING],];
Ankit Shah

Answers:


32

在中定义了3种不同的类型Magento/Framework/View/Design/ThemeInterface

  • 物理类型
  • 虚拟类型
  • 分期类型

物理主题

物理是指这些主题由文件定义的事实。例如,空白和亮度主题实际上是在app/design/frontend/

虚拟主题

尚不清楚,但我认为虚拟主题是指您可以在后端创建的主题,该主题扩展了现有的物理主题,但似乎尚未完全实现。

您可以看到,编辑部分中只有虚拟主题可用两个选项卡,您可以使用它们为虚拟主题提供自定义CSS和JS。

我认为虚拟主题是您在短期主题中临时设置的(例如圣诞节主题),与扩展的物理主题相比,只需很少的设计更改即可。

还没有可用的“添加虚拟主题”按钮,但是如果您运行以下SQL查询,则可以设置虚拟主题,并且在编辑该主题时会看到CSS和JS标签:

INSERT INTO `theme` (`theme_id`, `parent_id`, `theme_path`, `theme_title`, `preview_image`, `is_featured`, `area`, `type`, `code`) VALUES (NULL, '1', NULL, 'test', NULL, '0', 'frontend', '1', 'test/test');

接下来,您将看到两个额外的选项卡和“保存/删除”按钮:

在此处输入图片说明

舞台主题

我认为登台主题与Magento 2.1 EE登台功能有关:http : //devdocs.magento.com/guides/v2.1/extension-dev-guide/staging/Staging.html

我认为您可以在使用广告系列时使用登台主题,但我不确定100%。


您刚刚在这里解决了我的问题Raph!谢谢-Alvin :)
Alvin Nguyen

1
我遇到typetheme表格上的列的问题:我创建了一个主题,并以某种方式将其type值设置为1(而不是默认值0)。我所有的LESS / JS更改都起作用,但是Magento不会从主题中读取任何布局文件,除非将type值更改为0。此处的更多信息:nahuelsanchez.com/…–
埃里克·汉森
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.