Magento:如何在内容中的类别页面中调用静态块

时间:2022-09-24 23:13:48

I am trying to call a static cms block with id BLOCKID from within the content section of the category. I tried using the following and it doesn't work:

我试图从类别的内容部分中调用ID为BLOCKID的静态cms块。我尝试使用以下内容,但它不起作用:

{{block type="cms/block" block_id="BLOCKID"}}

I am able to call it using Custom Layout Update using the following code but it doesn't allow me control over the location where within content it will appear.

我可以使用以下代码使用自定义布局更新来调用它,但它不允许我控制它将出现在内容中的位置。

<reference name="content">
<block type="cms/block" name="BLOCKID">
<action method="setBlockId"><block_id>BLOCKID</block_id></action>
</block>
</reference>'

There is a specific section in my text located in the content section where I want this block to appear.

我的文本中有一个特定部分位于内容部分,我想要显示此块。

Any help would be appreciated.

任何帮助,将不胜感激。

1 个解决方案

#1


If you want to stick a static block into category content, there is an easy workaround. To keep things straight for this example, let's say the category is "Cameras" and your static block is "camera-deals".

如果您想将静态块粘贴到类别内容中,可以使用简单的解决方法。为了让这个例子保持正确,让我们说类别是“Cameras”,你的静态块是“camera-deals”。

  • Go to your category, copy all of the content.
  • 转到您的类别,复制所有内容。

  • Create a new static block named "cameras-content" or something similar
  • 创建一个名为“cameras-content”的新静态块或类似的东西

  • Paste your category content into this new static block, insert your existing "camera-deals" static block where you want it to go. Save
  • 将您的类别内容粘贴到这个新的静态块中,将现有的“camera-deals”静态块插入您想要的位置。保存

  • Return to the category, delete the content that you previously copied
  • 返回类别,删除先前复制的内容

  • In the Display tab, set Display Mode -> Static Block (can be either just the static block or with products, both work)
  • 在“显示”选项卡中,设置“显示模式” - >“静态块”(可以是静态块,也可以是产品,两者都可以)

  • Choose the "cameras-content" for your static block (this block can have variables and static blocks inside of it.) Save
  • 为静态块选择“cameras-content”(此块可以包含变量和静态块。)保存

Basically, it's easy to call files in the media folder, variables, blocks, and widgets from a static block...but out of the box you can't do that in category content. So just don't do that, haha. Have your category refer to a static block and then do all of your fancy things in that block.

基本上,从静态块中调用媒体文件夹,变量,块和小部件中的文件很容易......但是开箱即用,你不能在类别内容中这样做。哈哈,所以就这样做吧。让你的类别引用静态块,然后在该块中执行所有花哨的事情。

#1


If you want to stick a static block into category content, there is an easy workaround. To keep things straight for this example, let's say the category is "Cameras" and your static block is "camera-deals".

如果您想将静态块粘贴到类别内容中,可以使用简单的解决方法。为了让这个例子保持正确,让我们说类别是“Cameras”,你的静态块是“camera-deals”。

  • Go to your category, copy all of the content.
  • 转到您的类别,复制所有内容。

  • Create a new static block named "cameras-content" or something similar
  • 创建一个名为“cameras-content”的新静态块或类似的东西

  • Paste your category content into this new static block, insert your existing "camera-deals" static block where you want it to go. Save
  • 将您的类别内容粘贴到这个新的静态块中,将现有的“camera-deals”静态块插入您想要的位置。保存

  • Return to the category, delete the content that you previously copied
  • 返回类别,删除先前复制的内容

  • In the Display tab, set Display Mode -> Static Block (can be either just the static block or with products, both work)
  • 在“显示”选项卡中,设置“显示模式” - >“静态块”(可以是静态块,也可以是产品,两者都可以)

  • Choose the "cameras-content" for your static block (this block can have variables and static blocks inside of it.) Save
  • 为静态块选择“cameras-content”(此块可以包含变量和静态块。)保存

Basically, it's easy to call files in the media folder, variables, blocks, and widgets from a static block...but out of the box you can't do that in category content. So just don't do that, haha. Have your category refer to a static block and then do all of your fancy things in that block.

基本上,从静态块中调用媒体文件夹,变量,块和小部件中的文件很容易......但是开箱即用,你不能在类别内容中这样做。哈哈,所以就这样做吧。让你的类别引用静态块,然后在该块中执行所有花哨的事情。