最近,我首次安裝了Opencart 1.5.6。除了我試圖在子類別(精確搜索文本的位置)顯示圖像和文本以外,一切都正常。 到目前爲止,我已經把這個catalog\controller\module\category.php
在opencart的子類別中顯示圖像
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'image' => $category['image'],
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
$this->data['categories'][] = array(
'category_id' => $category['category_id'],
'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $total . ')' : ''),
'image' => $category['image'],
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
新東西是'image' => $category['image'],
。我也改變一點點catalog\view\theme\MYTHEME\template\product\category.tpl
像這樣:
<ul>
<?php foreach ($categories as $category) { ?>
<li>
<img src="../../../../../../image/data/models/<?php echo $category['image']; ?>" width="100"/>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
</li>
<?php } ?>
</ul>
<ul>
<?php $j = $i + ceil(count($categories)/4); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($categories[$i])) { ?>
<li>
<img src="../../../../../../image/data/models/<?php echo $categories['image']; ?>" width="100"/>
<a href="<?php echo $categories[$i]['href']; ?>"><?php echo $categories[$i]['name']; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
結果與圖像下破圖像和文本框。
我可以從錯誤看它是什麼,但不能弄清楚如何修復它 <img src="../../../../../../image/data/models/<b>Notice</b>: Undefined index: image in <b>..\catalog\view\theme\mytheme\template\product\category.tpl</b> on line <b>29</b>" width="100"/>
除了在HTML中不包含'../../../../../../ image/data/models /'之前,一切看起來都很好,因爲它包含正確的路徑...它只應該是' shadyyx
但是這次還是一樣的'注意:未定義的變量:我......並且沒有圖像。 – Goro
看起來你忘了'for-loop':'<?php for(; $ i <$ j; $ i ++){?>'應該是<?php for($ i = 0; $ i <$ j; $ i ++){?>',不是嗎? – shadyyx