如何以编程方式从布局中检索容器?
我希望能够执行以下操作...
$container = $layout->getContainer('name');
$container->setAttribute('htmlClass', 'class');
最佳答案
所以我就是那个人,尽量不要直接使用对象管理器。 To use or not to use the ObjectManager directly?
<?= $block->getLayout()->renderNonCachedElement('top-right-wrapper'); ?>
-or-
<?= $this->getLayout()->renderNonCachedElement('top-right-wrapper'); ?>
以上两个都可以使用,但不鼓励使用 $this。 Magento 2 Templates: Use
$block
or $this
?
关于magento2 - 在 Magento 2 中,如何从布局中检索容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38012953/