我想在我的自定义模块中添加元信息,我确实在AdminPanel中添加了选项卡和表单,其中包含字段
-
元标题,
-
元描述
-
元关键字
并将数据写入数据库,我想将此元信息添加到前端产品页面中,我不明白它是如何在前端与产品一起使用的,如有帮助,将不胜感激。。
您可以将其添加到Block以及您的控制器中
对于区块
在您的自定义块中添加此功能
protected function _prepareLayout()
{
$head = $this->getLayout()->getBlock('head');
if ($head) {
$head->setTitle("Your title");
$head->setKeywords("Your meta keywords");
$head->setDescription("Your meta description");
}
return parent::_prepareLayout();
}
对于控制器,您可以像一样添加
$this->getLayout()->getBlock('head')->setTitle('Manufacturer');
希望这一定能帮助你
在控制器中尝试此操作(保存表单操作);
$this->getLayout()->getBlock('head')->setTitle($title)->setDescription($description)->setKeywords($keywords);