Home » Blogs » Full Page Cache: Enterprise PageCache Model Container Placeholder

Full Page Cache: Enterprise PageCache Model Container Placeholder

How to work/flow Enterprise_PageCache_Model_Container_Placeholder class in Magento?
(Magento EE 1.13.0.2)Object: $this => Enterprise_PageCache_Model_Container_PlaceholderFollowing constant is used in above class:

  • const HTML_NAME_PATTERN = ‘//i’

Following variables is used in above class:

  • $_definitionMap
  • $_definition
  • $_name
  • $_attributes

Some important functions and its purpose used in this class:

  • getName(): This function is used for to get placeholder name.
  • getDefinition(): Get defination of placeholder.
  • getAttribute(): This function is used for get attribute by specific code.
  • getReplacer(): This function is used for get placeholder content replacer.
  • getStartTag(): This function return placeholder start tag for block html generation.
  • getEndTag(): This function return placeholder end tag for block html generation.

Functions in class Enterprise_PageCache_Model_Container_Placeholder
There are 10 functions used in class Enterprise_PageCache_Model_Container_Placeholder

  • /**Class constructor.
    * Initialize placeholder name and attributes based on definition
    * @param string $definition **/
    public function __construct($definition){}
  • /**Get placeholder name
    * @return string **/
    public function getName()
    {
    return $this->_name;
    }
  • /**Get placeholder definition
    * @return string **/
    public function getDefinition()
    {
    return $this->_definition;
    }
  • /**Get attribute by specific code
    * @param $code string
    * @return string **/
    public function getAttribute($code)
    {
    return isset($this->_attributes[$code]) ? $this->_attributes[$code] : null;
    }
  • /**Get regular expression pattern to replace placeholder content
    * @return string **/
    public function getPattern()
    {
    return ‘/’ . preg_quote($this->getStartTag(), ‘/’) . ‘(.*?)’ . preg_quote($this->getEndTag(), ‘/’) . ‘/ims’;
    }
  • /**Get placeholder content replacer
    * @return string **/
    public function getReplacer(){}
  • /**Get class name of container related with placeholder
    * @return string **/
    public function getContainerClass()
    {
    $class = $this->getAttribute(‘container’);
    if (strpos($class, ‘/’) !== false) {
    return Mage::getConfig()->getModelClassName($class);
    }
    return $class;
    }
  • ** Retrieve placeholder definition hash
    * @return string **/
    protected function _getDefinitionHash()
    {
    $definition = $this->getDefinition();
    $result = array_search($definition, self::$_definitionMap);
    if ($result === false) {
    $result = $this->getName() . ‘_’ . md5($definition);
    self::$_definitionMap[$result] = $definition;
    }
    return $result;
    }
  • **Get placeholder start tag for block html generation
    *
    * @return string
    */
    public function getStartTag()
    {
    return ‘‘;
    }
  • /**Get placeholder end tag for block html generation
    * @return string **/
    public function getEndTag()
    {
    return ‘‘;
    }

Variation of sample data for different pages (Homepage, Product Listing Page, Product Info Page)
Variables: These values for Homepage
URL:
https://localhost/oscp-store/mage-ent-test
$_definitionMap = array

  • /** Associative array of definition hash to informative definition **/
    WELCOME_8e20186cee9cf7a5a5d1e0bc75ddfec3 = WELCOME
    container = “Enterprise_PageCache_Model_Container_Welcome”
    block = “Mage_Page_Block_Html_Welcome”
    cache_id = “bf3668918d4f26657cdbfe6550c62f39a86211ba”
    cache_lifetime = “86400”
    template =””
  • $_definition=/***Original placeholder definition based on HTML_NAME_PATTERN **/
    WELCOME
    container = “Enterprise_PageCache_Model_Container_Welcome”
    block = “Mage_Page_Block_Html_Welcome”
    cache_id = “bf3668918d4f26657cdbfe6550c62f39a86211ba”
    cache_lifetime = “86400”
    template=””
  • $_name = WELCOME (Placeholder name)
  • $_attributes = /** * Placeholder attributes **/
    Array [5] container = Enterprise_PageCache_Model_Container_Welcome
    block = Mage_Page_Block_Html_Welcome
    cache_id = bf3668918d4f26657cdbfe6550c62f39a86211ba
    cache_lifetime = 86400
    template =

Variables: These values for product listing page
URL:
https://localhost/oscp-store/mage-ent-test/furniture/living-room

  • $_definitionMap = Array [2] [0]WELCOME_8e20186cee9cf7a5a5d1e0bc75ddfec3 = WELCOME
    container = “Enterprise_PageCache_Model_Container_Welcome”
    block = “Mage_Page_Block_Html_Welcome”
    cache_id = “bf3668918d4f26657cdbfe6550c62f39a86211ba”
    cache_lifetime = “86400”
    template=””[1]ACCLINKS_ef551a42665572f16be6f8a990c96b37 = ACCLINKS
    container =”Enterprise_PageCache_Model_Container_Accountlinks”
    block = “Mage_Page_Block_Template_Links”
    cache_id = “b8f9b3383abc7a26a71bfdc86c4a9d5bff6e3693”
    cache_lifetime = “86400”
    template = “page/template/links.phtml”
    links = garbage value
    name=”account.links”
  • $_definition = CART_SIDEBAR
    container = “Enterprise_PageCache_Model_Container_Sidebar_Cart”
    block = “Mage_Checkout_Block_Cart_Sidebar”
    cache_id = “3ee95d5974c12590e902688083b2097637487b5d” cache_lifetime=”86400″
    template = “checkout/cart/cartheader.phtml” item_renders=”default|checkout/cart_item_renderer|
    checkout/cart/sidebar/default.phtml|simple|checkout/cart_item_renderer|
    checkout/cart/sidebar/default.phtml|grouped|checkout/cart_item_renderer_grouped|
    checkout/cart/sidebar/default.phtml|configurable|
    checkout/cart_item_renderer_configurable|checkout/cart/sidebar/default.phtml|bundle|
    bundle/checkout_cart_item_renderer|checkout/cart/sidebar/default.phtml”
  • $_name = CART_SIDEBAR
  • $_attributes = Array [6] container = Enterprise_PageCache_Model_Container_Sidebar_Cart
    block = Mage_Checkout_Block_Cart_Sidebar
    cache_id = 3ee95d5974c12590e902688083b2097637487b5d
    cache_lifetime = 86400
    template = checkout/cart/cartheader.phtml
    item_renders = default|checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|simple|
    checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|grouped|
    checkout/cart_item_renderer_grouped|checkout/cart/sidebar/default.phtml|configurable|
    checkout/cart_item_renderer_configurable|checkout/cart/sidebar/default.phtml|bundle|
    bundle/checkout_cart_item_renderer|checkout/cart/sidebar/default.phtml

Variables: These values for product Info page
URL:
https://localhost/oscp-store/mage-ent-test/furniture/living-room/couch.html

  • $_definitionMap = Array [3] [0]WELCOME_8e20186cee9cf7a5a5d1e0bc75ddfec3 = WELCOME
    container = “Enterprise_PageCache_Model_Container_Welcome”
    block = “Mage_Page_Block_Html_Welcome”
    cache_id = “bf3668918d4f26657cdbfe6550c62f39a86211ba”
    cache_lifetime = “86400”
    template=””[1]ACCLINKS_ef551a42665572f16be6f8a990c96b37 = ACCLINKS
    container =”Enterprise_PageCache_Model_Container_Accountlinks”
    block =”Mage_Page_Block_Template_Links”
    cache_id = “b8f9b3383abc7a26a71bfdc86c4a9d5bff6e3693”
    cache_lifetime = “86400”
    template = “page/template/links.phtml”
    links = garbage value
    name=”account.links”[2]CART_SIDEBAR_ccd944c424b10c67d0f564f5cd4534e0 = CART_SIDEBAR
    container = “Enterprise_PageCache_Model_Container_Sidebar_Cart”
    block = “Mage_Checkout_Block_Cart_Sidebar”
    cache_id = “3ee95d5974c12590e902688083b2097637487b5d”
    cache_lifetime = “86400”
    template = “checkout/cart/cartheader.phtml”
    item_renders = “default|checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|simple|
    checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|grouped|
    checkout/cart_item_renderer_grouped|checkout/cart/sidebar/default.phtml|configurable|
    checkout/cart_item_renderer_configurable|checkout/cart/sidebar/default.phtml|bundle|
    bundle/checkout_cart_item_renderer|checkout/cart/sidebar/default.phtml”
  • $_definition = CART_SIDEBAR
    container =”Enterprise_PageCache_Model_Container_Sidebar_Cart”
    block = “Mage_Checkout_Block_Cart_Sidebar”
    cache_id = “3ee95d5974c12590e902688083b2097637487b5d”
    cache_lifetime = “86400”
    template = “checkout/cart/cartheader.phtml”
    item_renders = “default|checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|simple|
    checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|grouped|
    checkout/cart_item_renderer_grouped|checkout/cart/sidebar/default.phtml|configurable|
    checkout/cart_item_renderer_configurable|checkout/cart/sidebar/default.phtml|bundle|
    bundle/checkout_cart_item_renderer|checkout/cart/sidebar/default.phtml”
  • $_name = CART_SIDEBAR
  • $_attributes = Array [6] container = Enterprise_PageCache_Model_Container_Sidebar_Cart
    block = Mage_Checkout_Block_Cart_Sidebar
    cache_id = 3ee95d5974c12590e902688083b2097637487b5d
    cache_lifetime = 86400
    template = checkout/cart/cartheader.phtml
    item_renders = default|checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|simple|
    checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|grouped|
    checkout/cart_item_renderer_grouped|checkout/cart/sidebar/default.phtml|configurable|
    checkout/cart_item_renderer_configurable|checkout/cart/sidebar/default.phtml|bundle|
    bundle/checkout_cart_item_renderer|checkout/cart/sidebar/default.phtml

Leave A Comment