How to add custom dynamic block

After first rendering of page, extension check allow/disallow rules, cacheable actions and save this page (with all blocks) to cache. Then extension will return cached page without new rendering.

For update certain blocks extension provided an ability to define dynamic blocks.

Dynamic block - cached block with information which updated based on predefined conditions.

Native dynamic blocks:

  • page/html_header
  • checkout/cart_sidebar
  • page/html_wecome
  • reports/product_viewed
  • catalog/product_compare_sidebar
  • wishlist/customer_sidebar
  • page/template_links
  • page/html_notices
  • page/html_cookieNotice
  • cookienotice/notice (OptimiseWeb)

All dynamic blocks defined in files:

  • app/code/local/Mirasvit/Fpc/etc/cache.xml - contains native dynamic blocks
  • app/code/local/Mirasvit/Fpc/etc/custom.xml - contains custom (for current store) dynamic blocks

Structure of custom.xml file

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <containers>
        <zblock>
            <block>zblocks/block</block>
            <container>Mirasvit_Fpc_Model_Container_Base</container>
            <depends>rotator</depends>
            <in_app>1</in_app>
        </zblock>
    </containers>
</config>

where:

  • block - type of the block
  • container - the model, which implements logic of dynamic block cache

    In most cases, you can use Mirasvit_Fpc_Model_Container_Base

  • depends - the set of conditions for update block cache (comma seperator)

    • customer - current customer
    • customer_group - current customer group
    • cart - shopping cart
    • compare - compare list
    • wishlist - wishlist
    • product - current product
    • category - current category
    • store - current store
    • currency - current currency
    • locale - current locale
    • rotator - rotate block
    • empty value - constantly update block (always fresh)
  • in_app - logic for block update
    • 0 - allow block update without rendering whole page
    • 1 - update block only with rendering whole page