Magento:在自定义模板上放置块

发布于 2024-09-13 12:00:15 字数 467 浏览 4 评论 0原文

我们正在创建一个自定义页面,在其中制作产品向导,最后一步,我们想要拉入产品页面,实际上是 catalog/product_view 块。显然,我们可以创建该块并使用 renderview 方法将其设置在页面中,但我们遇到的问题是它只有该块而没有它的子块,并且由于 view.phtml< /code> 引入了大量的 getChildHtml 块,没有任何作用。

我认为必须有一种方法将产品视图块及其所有子视图放置在自定义非产品页面中。无需创建每个子块及其子块,是否有一种方法可以以编程方式拉取 xml 文件中的所有块,例如 catalog.xmlcatalog_product_view 句柄code> 并将其放在另一个页面上?

我们尝试将其放入的页面是一个使用自定义模板的类别页面,我们在模板文件中执行大量 PHP 操作来执行向导。

We are creating a custom page in which we are making something of a product wizard and the final step, we want to pull in the product page, really the catalog/product_view block. Obviously we can create the block and set it in the page with the renderview method but the problem we are having is its only that block and none of its children, and since the view.phtml pulls in a ton of getChildHtml blocks nothing works.

I am thinking there has to be a way to place the product view block with all of its children in a custom non product page. Without having to create every single child block and their child blocks, is there a way to programmatically pull in all the blocks that are in an xml file like the catalog_product_view handle in catalog.xml and place it on another page?

The page we are trying to put it on is a category page using a custom template where we are doing a lot of PHP in the template file to do the wizard.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你在我安 2024-09-20 12:00:15

你尝试过这样的事情吗?

//save the product in the registry so the block knows which product to display
$product = Mage::getModel('catalog/product')->load($productId);
Mage::register('product', $product);

//get the block from the layout and render it to html
$Block = Mage::getSingleton('core/layout');
$product_view = $Block->createBlock('catalog/product_view');
$product_view->setTemplate('catalog/product/view.phtml');
$product_view->toHtml();

我使用此代码取得了部分成功(显示了部分产品视图块,然后出现错误)。希望它能为您指明正确的方向。

Have you tried something like this?

//save the product in the registry so the block knows which product to display
$product = Mage::getModel('catalog/product')->load($productId);
Mage::register('product', $product);

//get the block from the layout and render it to html
$Block = Mage::getSingleton('core/layout');
$product_view = $Block->createBlock('catalog/product_view');
$product_view->setTemplate('catalog/product/view.phtml');
$product_view->toHtml();

I've had partial success with this code (part of the product view block is displayed and then I get an error). Hopefully it will point you in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文