在ECstore模板中,有些內容只想在首頁顯示,或者讓首頁和內頁有所區別,需要判斷當前頁面是否為首頁,方法如下:
在掛件的php中放置如下代碼:
$obj_base_component_request = kernel::single('base_component_request'); $ctl_name = $obj_base_component_request->get_ctl_name(); $act_name = $obj_base_component_request->get_act_name(); if ($ctl_name == 'default' && $act_name == 'index'){ $is_home = true; }
在掛件的html代碼中就可以這樣判斷了:
<{if $data.is_home}> <!--這里放置你的代碼--> <{/if}>