此代码在market.html 中编写
<?php echo $this->getLayout()->createBlock('core/template')->setData('vendorId',$vendor->getCustomerId())->setTemplate('marketplace/vendors/badge.phtml')->toHtml();?>
在Badge.php 中
echo $this->vendorId;
但是我的输出为空。这是将数据传递给块的正确方式吗?
您需要像这样更改变量并检查它
<?php echo $this->getLayout()->createBlock('core/template')->setVendorId($vendor->getCustomerId())->setTemplate('marketplace/vendors/badge.phtml')->toHtml();?>
现在,您可以访问badge.phtml文件中的供应商ID变量,如下所示:
<?php echo $this->getVendorId();?>