我正面临一个非常奇怪的故障。因此,我试图用下面的代码{{block type="core/template" name="ves_random_products" template="page/RandomProducts.phtml"}}
为我的家添加一个块,它工作得很好,可以显示集合中的随机产品等等,小菜一碟。
现在的问题是,我正在使用一个完整的页面缓存扩展,我需要使这个块动态,问题是Magento似乎不使用"ves_random_products"作为块名称,当加载页面时,我的块没有名称(匿名/匿名),当我执行var_dump(Mage::app()->getLayout()->getAllBlocks());
时,块的名称显示为"anonymous_0"。最奇怪的是,在Mage::app()->getLayout()->getAllBlocks()
中,我可以看到参数"name"的值为"ves_random_products"。var_dump的完整输出为:
array(1) {
["ANONYMOUS_0"]=>
object(Mage_Core_Block_Template)#243 (31) {
["_viewDir":protected]=>
string(32) "/var/www/html/magento/app/design"
["_viewVars":protected]=>
array(0) {
}
["_baseUrl":protected]=>
NULL
["_jsUrl":protected]=>
NULL
["_allowSymlinks":protected]=>
NULL
["_template":protected]=>
string(25) "page/RandomProducts.phtml"
["_nameInLayout":protected]=>
string(12) "ANONYMOUS_0"
["_layout":protected]=>
object(Mage_Core_Model_Layout)#192 (15) {
["_update":protected]=>
object(Mage_Core_Model_Layout_Update)#191 (7) {
["_elementClass":protected]=>
NULL
["_packageLayout":protected]=>
NULL
["_cacheId":protected]=>
NULL
["_cachePrefix":protected]=>
NULL
["_updates":protected]=>
array(0) {
}
["_handles":protected]=>
array(7) {
["default"]=>
int(1)
["cms_page"]=>
int(1)
["STORE_fsview"]=>
int(1)
["THEME_frontend_default_ves_superstore"]=>
int(1)
["cms_index_index"]=>
int(1)
["page_one_column"]=>
int(1)
["customer_logged_out"]=>
int(1)
}
["_subst":protected]=>
array(2) {
["from"]=>
array(2) {
[0]=>
string(11) "{{baseUrl}}"
[1]=>
string(17) "{{baseSecureUrl}}"
}
["to"]=>
array(2) {
[0]=>
string(26) "http://mystore.com/"
[1]=>
string(27) "https://mystore.com/"
}
}
}
["_blocks":protected]=>
*RECURSION*
["_output":protected]=>
array(0) {
}
["_area":protected]=>
string(8) "frontend"
["_helpers":protected]=>
array(0) {
}
["_directOutput":protected]=>
bool(false)
["_xml":protected]=>
object(Mage_Core_Model_Layout_Element)#40 (0) {
}
["_cacheId":protected]=>
NULL
["_cacheTags":protected]=>
array(0) {
}
["_cacheLifetime":protected]=>
NULL
["_cacheChecksum":protected]=>
bool(false)
["_cacheSaved":protected]=>
bool(false)
["_cache":protected]=>
NULL
["_elementClass":protected]=>
string(30) "Mage_Core_Model_Layout_Element"
["_xpathExtends":protected]=>
string(13) "//*[@extends]"
}
["_parent":protected]=>
NULL
["_alias":protected]=>
NULL
["_anonSuffix":protected]=>
NULL
["_children":protected]=>
array(0) {
}
["_sortedChildren":protected]=>
array(0) {
}
["_childrenHtmlCache":protected]=>
array(0) {
}
["_childGroups":protected]=>
array(0) {
}
["_request":protected]=>
NULL
["_messagesBlock":protected]=>
NULL
["_isAnonymous":protected]=>
bool(true)
["_parentBlock":protected]=>
NULL
["_frameOpenTag":protected]=>
NULL
["_frameCloseTag":protected]=>
NULL
["_sortInstructions":protected]=>
array(0) {
}
["_factory":protected]=>
NULL
["_app":protected]=>
NULL
["_data":protected]=>
array(5) {
["type"]=>
string(13) "core/template"
["name"]=>
string(19) "ves_random_products"
["template"]=>
string(25) "page/RandomProducts.phtml"
["block_params"]=>
array(3) {
["type"]=>
string(13) "core/template"
["name"]=>
string(19) "ves_random_products"
["template"]=>
string(25) "page/RandomProducts.phtml"
}
["module_name"]=>
string(9) "Mage_Core"
}
["_hasDataChanges":protected]=>
bool(true)
["_origData":protected]=>
NULL
["_idFieldName":protected]=>
NULL
["_isDeleted":protected]=>
bool(false)
["_oldFieldsMap":protected]=>
array(0) {
}
["_syncFieldsMap":protected]=>
array(0) {
}
}
}
我试图让这个街区有个名字,但没有成功,我做错了什么?浏览了整个互联网,似乎只有我一个人面临这个问题(?!)。奇怪的这是核心故障吗?谢谢
我不确定,但由于看起来像是在CMS中添加块,我认为这个名称被忽略了。您可能需要将其保存在布局XML中,以便将其实际计算为命名。
不管怎样,我不认为仅仅命名它就能解决你的主要问题,你需要的是在FPC上打孔-使用这种方法可能会有所帮助:
https://magento.stackexchange.com/questions/35140/static-block-fpc-hole-punch