
产品控制器使用助手来设置活动产品。您应该能够在控制器中执行相同的 *** 作!
在进行布局之前,请尝试以下 *** 作:
$productId = (int) $this->getRequest()->getParam('id');Mage::helper('catalog/product')->initProduct($productId, $this);要注意的另一件事:如果添加诸如product.info块之类的块。如果在其模板文件中调用它们,则需要其他子块。
使用自定义布局xml文件将是最简单的。然后,您可以为 *** 作句柄添加特定的布局(您的 *** 作句柄由模块中的etc /
config.xml文件中的routers节点组成
<frontend><routers>,例如
<Yourmodule>node,请确保将其小写!然后用下划线添加控制器名称和 *** 作名称,在您的情况下为index_index),如下所示:
<yourmodule_index_index> <remove name="right"/> <remove name="left"/> <block type="catalog/product_view" name="root" output="toHtml" template="catalog/product/view.phtml"> <!-- Add all the child blocks you need --> </block></yourmodule_index_index>
这使view.phtml成为使用其toHtml方法呈现自身的根块。因此,在您的控制器 *** 作中,您需要做的就是上面的两行,然后:
$this->loadLayout();$this->renderLayout();
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)