欲しいですgetBlock Adb/Block/Index in controller Adb/Controller/Category/View
。それでどうやって?
編集する
コントローラ内。
namespace Addon\Faq\Controller\Category;
class View extends \Addon\Faq\Controller\Category
{
/**
* @var \Magento\Framework\Controller\Result\ForwardFactory
*/
protected $_coreRegistry = null;
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory ;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Registry $registry
) {
$this->resultPageFactory = $resultPageFactory;
$this->_coreRegistry = $registry;
parent::__construct($context);
}
/**
* Product list page
*
* @return \Magento\Backend\Model\View\Result\Page
*/
public function execute()
{
$resultPage = $this->resultPageFactory ->create();
$blockInstance = $resultPage->getLayout()->getBlock('category.index');
}
}
フロントエンドのレイアウト
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Addon\Faq\Block\Faq" name="category.index" template="Addon_Faq::view.phtml"/>
</referenceContainer>
</body>
</page>
ブロックFAQとは呼ばない