1

我已经创建了一个自定义布局,并且我计划只为那些自定义布局分配的页面隐藏产品。

有什么方法可以获取当前布局 id 吗?

例如,假设我的自定义 layout_id 为 10,我计划使用如下所示的循环来隐藏/显示产品

if (current_layout_id != 10) {
  // Display products
}else {
  // Hide Products
}
4

1 回答 1

2

查找当前显示的模块页面的布局ID

if (isset($this->request->get['route'])) { 
        $route = $this->request->get['route']; 
    } else { 
        $route = 'common/home'; 
    }
    $layout_id = 0;
    if (substr($route, 0, 16) == 'product/category' && isset($this->request->get['path'])) {
        $path = explode('_', (string)$this->request->get['path']);
        $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
    }
    if (substr($route, 0, 16) == 'product/product' && isset($this->request->get['product_id'])) {
        $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
    }
    if (substr($route, 0, 16) == 'product/information' && isset($this->request->get['information_id'])) {
        $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
    }
    if (!$layout_id) { $layout_id = $this->model_design_layout->getLayout($route); }
    if (!$layout_id) { $layout_id = $this->config->get('config_layout_id'); }

布局ID查找结束

于 2013-08-08T11:13:11.417 回答