【问题标题】:Can a Product follows two Product Description template in Magento一个产品可以遵循 Magento 中的两个产品描述模板吗
【发布时间】:2013-07-09 20:32:21
【问题描述】:

我想在产品列表页面上提供两个按钮,一个用于添加到购物车,第二个用于自定义产品。现在,当客户单击添加到购物车时,它应该转到产品描述页面。如果他点击自定义按钮,那么它应该转到其他页面,他可以在其中更改产品设计(可以自定义 T 恤等)。我已经为两个页面创建了两个 phtml 文件。现在我希望页面控件转到正确的页面(取决于单击)。我已经为类别产品设置了 phtml 文件。但是如何为产品描述页面设置两个 phtml 文件单一类别。

【问题讨论】:

    标签: php magento


    【解决方案1】:

    问题有点不清楚,但如果我理解正确,您可以根据要显示的信息在 url 中添加一个参数。我们称它为“显示”(一个简单的 1|0 标志应该可以)。
    在产品视图页面中添加如下内容:

    <?php if (Mage::app()->getRequest()->getParam('show')) : ?>
        //display some content
    <?php else : ?>
        //display other content
    <?php endif;?>
    

    【讨论】:

    • 我不确定您是否需要其他模板。您可以创建 2 个具有 2 个不同名称的不同块并显示其中一个,具体取决于具体情况。或者如果你坚持,你可以在调用echo $this-&gt;getChildHtml('child_name_here')之前尝试$this-&gt;getChild('child_name_here')-&gt;setTemplate('alternative/template.phtml')之类的东西
    • 我已经创建了两个模板。现在我必须在单击按钮后调用 $this->getChild('child_name_here')->setTemplate('alternative/template.phtml') 这段代码。
    • 您可以在我的回答中的 if 语句中调用它。根据通过 GET 发送的 var 更改模板
    • 我在侧视图.phtml 中没有找到任何 GET
    • 仔细阅读我的回答。通过 GET (product.phtml?show=1) 向产品页面发送一个参数,然后使用该参数更改产品 view.phtml 文件中某个块的模板或显示一个或另一个块。
    猜你喜欢
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    • 1970-01-01
    相关资源
    最近更新 更多