Magento layout rendering mystery

今天碰到个问题百思不得其解。起因是我在改进 Magento rcah module 时,想在 category/index/view 输出前修改 head block 里其中一个 item: link_rel。 具体说来,我想调用 $headBlock->removeItem()->addLinkRel() 把修改过的 link_rel 添加到 head block 的 $_data[‘items’]。由于调用在 renderLayout() 之后,所以 head 在输出时仍然是修改前的 link_rel。这本不奇怪;奇怪的是,我观察到 $headBlock->getCssJsHtml() 在整个过程中只执行了一次,而且是在 $headBlock->removeItem()->addLinkRel() 之后,$headBlock->getCssJsHtml() 应该是跟 html 输出直接相关,为什么在 $headBlock->getCssJsHtml() 看来 link_rel 还是原值? Layout rendering 机制对我来说还比较神秘。我只能暂时这么解释: renderLayout() 时把所有 block 的状态记住了,所以此后再怎么修改 block 的状态都无济于事。到了输出 html 阶段,所有的输出都是以 renderLayout() 时的 block。 BTW,在 rcah 模块中,我找到一个非常巧妙的办法来修改 link_rel… Continue reading Magento layout rendering mystery

Magento extension: rcah 0.2.0 is released

In previous version of rcah module, if “Use Canonical Link Meta Tag For Categories” is enabled in System >> Configuration >> Catalog >> Search Engine Optimizations, and if you set a root category as homepage, the homepage html head outputs a link like <link rel=”canonical” href=”http://MY_DOMAIN/catalog/category/view/s/URL_KEY/id/ROOT_CATEGORY_ID/” /> or if you set a subcategory as homepage… Continue reading Magento extension: rcah 0.2.0 is released

Install SSL certificate on Nginx step by step

Although I have installed SSL certificates for several times, every time I google step by step guide. So now I take my own note: Step 1: Generate key $ openssl genrsa -des3 -out verisign-mydomain.co.uk.key 1024 Generating RSA private key, 1024 bit long modulus ………………….++++++ …………………++++++ e is 65537 (0x10001) Enter pass phrase for verisign-mydomain.co.uk.key: Verifying… Continue reading Install SSL certificate on Nginx step by step