【问题标题】:Magento how to call phtml file as a block on cms page?Magento如何在cms页面上调用phtml文件作为一个块?
【发布时间】:2017-01-17 10:23:19
【问题描述】:

我正在使用 magento 1.9.1 并尝试直接在 cms 页面上创建产品链接。我创建了一个 custombutton.phtml 文件并在此处添加按钮代码。

<?php $formKey = Mage::getSingleton('core/session')->getFormKey(); ?>
<a class="animated infinite swing btn btn-yellow btn-lg m-r-2" role="button" href="abc.com/checkout/cart/add?product=401&qty=1&form_key=<?php echo $formKey ?>">Add to cart</a>

现在我将此 phtml 文件称为 cms 页面上的块。

  {{block type="core/template" name="custombutton" template="custombutton.phtml"}}

但有时它显示按钮,有时不显示。没有得到问题。

【问题讨论】:

  • 我认为缓存块时会出现问题。
  • 缓存在网站上被禁用。

标签: magento


【解决方案1】:

请授予阻止 goto->system->permissions->block 的权限 并添加您的块名称。希望这会有所帮助

【讨论】:

  • block type="core/template" 默认是允许的
猜你喜欢
  • 2012-09-30
  • 1970-01-01
  • 2016-03-21
  • 2016-09-19
  • 2015-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多