简体   繁体   English

如何设置lesti:FPC以使用动态模板?

[英]How to set up lesti:FPC to work with dynamic templates?

I'm would like to use lesti:FPC with a module I developed. 我想将lesti:FPC与我开发的模块一起使用。

To enable SEO friendly urls ALL requests to the module are sent to the module index action, and there a template is dynamically loaded. 为了启用SEO友好的url,所有对模块的请求都将发送到模块索引操作,并在那里动态加载模板。 How can I make lesti:FPC work under this scenario? 在这种情况下,如何使lesti:FPC工作?

On the module layout file (../layout/addon.xml) I have: 在模块布局文件(../layout/addon.xml)中,我具有:

<block type="addon/index" name="addon_index" template="addon/index.phtml"/>

On the module indexAction I have: 在模块indexAction上,我有:

if($condition)
{
  $this->getLayout()->getBlock('addon_index')->setTemplate('addon/a.phtml');
}
else
{
  $this->getLayout()->getBlock('addon_index')->setTemplate('addon/b.phtml');
}

Would adding 'addon_index' to the lesti:FPC layout-handles be enough to get my module pages cached? 在lesti:FPC布局句柄中添加'addon_index'是否足以缓存我的模块页面?

Calling Dynamic Block in Lesti Fpc depends on conditions can be done using observer 

**Config.xml**

<frontend>
        <events>
            <core_block_abstract_to_html_before>
                <observers>
                    <atwix_test>
                        <type>model</type>
                        <class>namspace_test/observer</class>
                        <method>insertBlock</method>
                    </atwix_test>
                </observers>
            </core_block_abstract_to_html_before>
        </events>
    </frontend>

class Namespace_Test_Model_Observer
{
    public function insertBlock($observer)
    {
        /** @var $_block Mage_Core_Block_Abstract */
        /*Get block instance*/
        $_block = $observer->getBlock();
        /*get Block type*/
        $_type = $_block->getType();
       /*Check block type*/
        if ($_type == 'catalog/product_price') {
            /*Clone block instance*/
            $_child = clone $_block;
            /*set another type for block*/
            $_child->setType('test/block');
            /*set child for block*/
            $_block->setChild('child', $_child);
            /*set our template*/
            $_block->setTemplate('at.phtml');
        }
    }
}

And finally, here is a template at.phtml code: 最后,这是at.phtml代码的模板:

echo $this->getChildHtml('child'); echo $ this-> getChildHtml('child');

Hope it will help you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Magento-将HTML HEAD标记声明为LESTI FPC中的动态块 - Magento - Declare HTML HEAD tag as dynamic block in LESTI FPC Magento FPC Cache使用用户组,wget,Lesti FPC热情 - Magento FPC Cache Warm with user groups, wget, Lesti FPC Lesti的FPC无法与Fishpig一起使用获得帖子收集 - Lesti's FPC not working with Fishpig get post collection Magento-当我使用脚本更改数据库中的库存时,使用lesti fpc的特定产品清洁缓存 - Magento - Specific product clean cache using lesti fpc when i change stock in the database using script 忽略XML类别更新+ Manadev过滤器问题 - Magento 1.9 Lesti FPC 1.4.8 - XML category update ignored + Manadev filter problem - Magento 1.9 Lesti FPC 1.4.8 FPC在magento上时如何获取产品详细信息 - How to get product details when FPC is on magento 如何从magento中的Zoom FPC缓存中排除顶部链接 - How to exlude top links from Zoom FPC cache in magento Magento如何从Lest Fpc启用GeoIP扩展 - Magento how to enable with GeoIP extension from Lest Fpc Magento 1.9 - Amasty FPC:如何永久忽略一个块 - Magento 1.9 - Amasty FPC: How do I ignore a block permanently Magento企业显示错误结果以在FPC缓存的产品列表页面中显示动态数据 - Magento enterprise showing wrong result to show dynamic data in product listing page for FPC cache
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM