Na forum Opencart znalazłem info jak dokonać zmian, żeby wszystkie kategorie były wyświetlane na stronie głównej. Być może właśnie o to Ci chodzi.
W pliku catalog\controller\common\home.php znajdujemy linijki:
- Kod: Zaznacz cały
$this->load->model('tool/image');
$this->data['products'] = array();
I pomiędzy wstawiamy kod (zachowane są tutaj oryginalne komentarze autora poprawki):
- Kod: Zaznacz cały
/* START: Added for homepage category hacks */
$this->load->model('catalog/category');
//Set Category for display
$category_id = '0';
//Get total categories in your category
$category_total = $this->model_catalog_category->getTotalCategoriesByCategoryId($category_id);
$this->data['products'] = array();
if (isset($category_total)) {
$this->data['categories'] = array();
$results = $this->model_catalog_category->getCategories($category_id);
foreach ($results as $result) {
if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}
$this->data['categories'][] = array(
'name' => $result['name'],
//'href' => $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $result['category_id'])),
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $result['category_id']),
//'thumb' => image_resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
);
}
$this->id = 'content';
$this->template = $this->template = 'default/template/common/home.tpl';
$this->layout = 'common/layout';
$this->render();
}
/* END: Added for homepage category hacks */
Teraz w pliku catalog\view\theme\default\template\common\home.tpl podmieniamy kod na poniższy (gdzie produkty są w komentarzu i nie będą wyświetlane):
- Kod: Zaznacz cały
<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content">
<div class="top">
<div class="left"></div>
<div class="right"></div>
<div class="center">
<h1><?php echo $heading_title; ?></h1>
</div>
</div>
<div class="middle">
<div><?php echo $welcome; ?></div>
<div class="heading"><?php echo $text_latest; ?></div>
<?php /* START: Added for homepage category hacks */ ?>
<?php if ($categories) { ?>
<table class="list">
<?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) { ?>
<tr>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<td width="25%"><?php if (isset($categories[$j])) { ?>
<a href="<?php echo $categories[$j]['href']; ?>"><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" style="margin-bottom: 3px;" /></a><br />
<a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?></a>
<?php } ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
<?php } ?>
<?php /* END: Added for homepage category hacks */ /* ?>
<table class="list">
<?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
<tr>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<td style="width: 25%;"><?php if (isset($products[$j])) { ?>
<a href="<?php echo str_replace('&', '&', $products[$j]['href']); ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" /></a><br />
<a href="<?php echo str_replace('&', '&', $products[$j]['href']); ?>"><?php echo $products[$j]['name']; ?></a><br />
<span style="color: #999; font-size: 11px;"><?php echo $products[$j]['model']; ?></span><br />
<?php if ($display_price) { ?>
<?php if (!$products[$j]['special']) { ?>
<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span><br />
<?php } else { ?>
<span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
<?php } ?>
<?php } ?>
<?php if ($products[$j]['rating']) { ?>
<img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
<?php } ?>
<?php } ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
<?php */ ?>
</div>
<div class="bottom">
<div class="left"></div>
<div class="right"></div>
<div class="center"></div>
</div>
</div>
<?php echo $footer; ?>