Jump to content
Sign in to follow this  
sliktovich

отображение каталога на главной странице

Recommended Posts

Здравствуйте, прошу помочь с советом.

На главной странице главные пункты каталога http://i.imgur.com/cT3K1aX.png

При нажатии,допустим на сатехнику, появляются дочерние категории в виде картинки, заголовка и описания. http://i.imgur.com/Hvg93IC.png

Как сделать, чтобы на главной странице отображались так же главные категории,  с картинкой, заголовком и описанием?

Так отображаются дочерние категории.

<?php if ($categories) { ?>
  <div class="box-category">
    <?php foreach ($categories as $category) { ?>
	
	<ul>
	<li>
      <div class="image"><a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" title="<?php echo $category['name']; ?>" alt="<?php echo $category['name']; ?>" /></a></div>
      <div class="name"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a><br></div>
	  <div class="description_one"><?php if ($category['description_one']) { ?> <?php echo $category['description_one']; ?><?php } ?></div>
	  </li> 
	</ul>

    <?php } ?>
  </div>
  <?php } ?>

Share this post


Link to post
Share on other sites

Опять же перефразирую, как мне указать, чтобы он из базы брал только главные пункты каталога и отображал их?

<?php  
class ControllerModuleCategory extends Controller {
	protected function index($setting) {
		$this->language->load('module/category');
		
    	$this->data['heading_title'] = $this->language->get('heading_title');
		
		if (isset($this->request->get['path'])) {
			$parts = explode('_', (string)$this->request->get['path']);
		} else {
			$parts = array();
		}
		
		if (isset($parts[0])) {
			$this->data['category_id'] = $parts[0];
		} else {
			$this->data['category_id'] = 0;
		}
		
		if (isset($parts[1])) {
			$this->data['child_id'] = $parts[1];
		} else {
			$this->data['child_id'] = 0;
		}
		
		if (isset($parts[2])) {
			$this->data['ch3_id'] = $parts[2];
		} else {
			$this->data['ch3_id'] = 0;
		}
							
		$this->load->model('catalog/category');

		$this->load->model('catalog/product');

		$this->data['categories'] = array();

		$categories = $this->model_catalog_category->getCategories(0);
		
		foreach ($categories as $category) {
			$total = $this->model_catalog_product->getTotalProducts(array('filter_category_id'  => $category['category_id']));

			$children_data = array();

			$children = $this->model_catalog_category->getCategories($category['category_id']);

			foreach ($children as $child) {
				$data = array(
					'filter_category_id'  => $child['category_id'],
					'filter_sub_category' => true
				);
				
				$product_total = $this->model_catalog_product->getTotalProducts($data);
				$level3 = $this->model_catalog_category->getCategories($child['category_id']);
				$l3_data = array();
				foreach ($level3 as $l3) {
					$l3_data[] = array(
						'category_id' => $l3['category_id'],
						'name'        => $l3['name'],
						'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']. '_' . $l3['category_id'])
					);
				}
				

				$total += $product_total;

				$children_data[] = array(
					'category_id' => $child['category_id'],
					'name'        => $child['name'], // . ' (' . $product_total . ')',
					'children'    => $l3_data,
					'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'], // . ' (' . $product_total . ')',
				'children'    => $children_data,
				'href'        => $this->url->link('product/category', 'path=' . $category['category_id'])
			);	
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/category.tpl';
		} else {
			$this->template = 'default/template/module/category.tpl';
		}
		
		$this->render();
  	}

}
?>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.