将 Opencart 站点地图拆分为多列
Split Opencart Sitemap into multiple columns
我使用的是 opencart 2.0.1.1,在 information/sitemap 中,站点地图中的类别列在一栏中,因为我有很多类别,所以它只在一栏中生成长列表。
我想弄清楚是否可以将类别拆分为多列以使其看起来不错。我尝试使用 array_chunk 或插入一个 if 条件来拆分成不同的列,但它不起作用。
这是当前代码。
$data['categories'] = array();
$categories_1 = $this->model_catalog_category->getCategories(0);
foreach ($categories_1 as $category_1) {
$level_2_data = array();
$categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);
foreach ($categories_2 as $category_2) {
$level_3_data = array();
$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
foreach ($categories_3 as $category_3) {
$level_3_data[] = array(
'name' => $category_3['name'],
'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id'])
);
}
$level_2_data[] = array(
'name' => $category_2['name'],
'children' => $level_3_data,
'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'])
);
}
$data['categories'][] = array(
'name' => $category_1['name'],
'children' => $level_2_data,
'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'])
);
}
使用 css 多列 属性 解决了这个问题:
column-count
column-gap
column-rule-style
column-rule-width
column-rule-color
column-rule
column-span
column-width</pre>
虽然不是均匀的网格,但它可以将一列分成多列。不是一个理想的解决方案,但正在完成这项工作。
我使用的是 opencart 2.0.1.1,在 information/sitemap 中,站点地图中的类别列在一栏中,因为我有很多类别,所以它只在一栏中生成长列表。
我想弄清楚是否可以将类别拆分为多列以使其看起来不错。我尝试使用 array_chunk 或插入一个 if 条件来拆分成不同的列,但它不起作用。 这是当前代码。
$data['categories'] = array();
$categories_1 = $this->model_catalog_category->getCategories(0);
foreach ($categories_1 as $category_1) {
$level_2_data = array();
$categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);
foreach ($categories_2 as $category_2) {
$level_3_data = array();
$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
foreach ($categories_3 as $category_3) {
$level_3_data[] = array(
'name' => $category_3['name'],
'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id'])
);
}
$level_2_data[] = array(
'name' => $category_2['name'],
'children' => $level_3_data,
'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'])
);
}
$data['categories'][] = array(
'name' => $category_1['name'],
'children' => $level_2_data,
'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'])
);
}
使用 css 多列 属性 解决了这个问题:
column-count column-gap column-rule-style column-rule-width column-rule-color column-rule column-span column-width</pre>
虽然不是均匀的网格,但它可以将一列分成多列。不是一个理想的解决方案,但正在完成这项工作。