gpt4 book ai didi

magento2 - 在 magento2 运行时设置包和主题

转载 作者:行者123 更新时间:2023-12-04 22:32:21 24 4
gpt4 key购买 nike

我的包名是“company”,我的主题名是“web”,我还有另一个包名为“system”,其主题名为“component”。

运行时间来自 Block 文件,但我想从 magento2 的前端设置该主题和包。

最佳答案

如果您想在运行时在 magento 中设置包和主题,只需使用此代码片段。

  • 创建一个函数,例如。 changeTheme('主题名称');并根据您的要求运行此函数
  • 在 php 启动后在你的 head.phtml 中添加这个函数。
     function changeTheme($themeName)
    {
    Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml)
    ->setPackageName('default') //Name of Package
    ->setTheme($themeName); // Name of theme
    }

  • 请享用 :)

    关于magento2 - 在 magento2 运行时设置包和主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17649587/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com