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.

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

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化