doutun9179 2014-03-22 12:33
浏览 17
已采纳

Magento:添加2个或更多静态块以让类别内容介于两者之间

I manage to add static blocks to my category pages, but what I am looking for now is to make my category contents runs between these static blocks, for example:

(static block contents)

(category contents)

(another static block contents)

so I can add simple contents in "General Information" "Description" area and the complicated slideshow and other common blocks runs in static blocks.

I hope I was clear in my question and thank you all in advance

  • 写回答

1条回答 默认 最新

  • dqwcdqs358367 2014-03-24 02:40
    关注

    The quickest way to achieve this is to add your static blocks in category_view page.

    So these are the hints that you can refer with

    1) Create two static blocks through admin (go to CMS -> static blocks and then add a new one). Let block identifiers be top-category-static-block and bottom--category-static-block. Make sure two blocks are enabled.

    2) Go to

    Location : app/design/frontend/<your_package>/<your_theme>/template/catalog/category/view.phtml

    add the following code top of this file.

    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top-category-static-block')->toHtml() ?>
    

    add the following code bottom of this file

     <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('bottom-category-static-block')->toHtml() ?>
    

    Remove the cache and then refresh the page. You can see the contents of your static blocks in respective places.

    EDIT

    You can add any number of static blocks in anywhere any number of times. Use of the above snippet is endless and I think it has no restrictions.

    Answer for your doubts reside in this answer itself. I will explain it again for sake your best understanding

    1)Is it possible to add static block in different pages?

    Yes you can. For this you need to find the phtml file that render the content of desired page. Analyze the content in that page carefully and find the appropriate position and add the above code there. For example, above we added the code top and bottom of the category_view page. Similarly you need to find the appropriate position.

    2)Is it possible to add a static block middle of category page?

    Yes obviously. Why can't you make a try on the category _view file? Just try to add the above code snippet, somewhere middle of the page. It will do the magic

    In magento, there may be lot of blocks that constitutes your particular page. For example, your category page constitutes by several number of blocks. Each part of the category page is rendering by different blocks. You can find every blocks that constitutes a category page in catalog.xml (Generally in layout file). So some time you may need to dig deeper to find the exact block in which you need to add the above the code in order to get the desired output. In initial stage, it may be a tough job. Later things will become more easy.

    Don't give up. Good luck.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 使用php如何制作一个国博门票抢票系统?(相关搜索:手机号|小程序)
  • ¥15 关于#数据库#的问题:每次实验都是系统直接导出数据,但是实验过程前会修改被实验件的结构类型,软件版本(如第一次实验为结构A,A01版本软件,A01版本软件)(相关搜索:数据类型)
  • ¥15 群晖docker无法连接代理服务器
  • ¥20 VBA将EXCEL数据写入JSON,中文不显示
  • ¥15 用S7-200 SIM 2.0,导入程序时出现了这个问题(关键词-子程序)
  • ¥15 pip安装pystan显示No module named 'Cython'的问题
  • ¥15 求一下解题思路,需完整的步骤和代码。
  • ¥15 苹果CMS搭建的视频网站首页打开为什么会自动跳转到色情页面?
  • ¥15 php,mysql的问题
  • ¥50 dac adc的检定规程