Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

управление столбиками выпадающего меню категорий 2-го уровня


Recommended Posts

Добрый день, возникла следующая необходимость, управление расположением категорий 2-го уровня (подкатегории) в столбцах выпадающего меню.

Меню "из коробки":

<div id="menu">
  <ul>
	    <?php foreach ($categories as $category) { ?>
	    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
		  <?php if ($category['children']) { ?>
		  <div>
			    <?php for ($i = 0; $i < count($category['children']);) { ?>
			    <ul>
				  <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
				  <?php for (; $i < $j; $i++) { ?>
				  <?php if (isset($category['children'][$i])) { ?>
				  <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
				  <?php } ?>
				  <?php } ?>
			    </ul>
			    <?php } ?>
		  </div>
		  <?php } ?>
	    </li>
	    <?php } ?>
  </ul>
</div>

Как привязать значение "Порядок сортировки", чтоб оно так-же определяло номер колонки (первая, вторая, или третья...) в которой эта подкатегория будет отображаться?

Link to comment
Share on other sites


...в БД "Порядок прорисовки" записывается в oc_category > sort_order, так вот, как привязать отображение подкатегории в той или иной колонке, согласно значение sort_order = № колонки выпадающего меню ?

както так ...

Колонка 1 | Колонка 2 | Колонка 3 |

parent_id 1 sort_order 1 category_id1 | parent_id 2 sort_order 2 category_id2 | parent_id 3 sort_order 3 category_id3 |

parent_id 1 sort_order 1 category_id4 | parent_id 2 sort_order 2 category_id5 | parent_id 3 sort_order 3 category_id6 |

parent_id 1 sort_order 1 category_id21 | parent_id 2 sort_order 2 category_id56 | parent_id 3 sort_order 3 category_id78 |

Link to comment
Share on other sites


линк на меню? про колонки плохо понял

Изображение

шины с посадочным радиусом R12 (parent_id 1, sort_order 1,....) должны размещаться в первой колонке, шины с посадочным R13 (parent_id 1, sort_order 2,....) во второй колонке, R14 (parent_id 1, sort_order 3,....) в третьей и т.д. .....

Значение sort_order 3 должно определять колонку в которой будет отображаться та или иная подкатегория.

Link to comment
Share on other sites


  • 5 months later...

1. В фале controller\common\header.php ищите строки

 $children_data[] = array(
  'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
  'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])

заменяете на:

 $children_data[] = array(
  'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
  'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
  'sort_order'=> $child['sort_order']

2. В файле тема\template\common\header.tpl ищите строки

	<?php for ($i = 0; $i < count($category['children']);)/> { ?>
	<ul>
	  <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
	  <?php for (; $i < $j; $i++) { ?>
	  <?php if (isset($category['children'][$i])) { ?>
	  <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
	  <?php } ?>
	  <?php } ?>
	</ul>
	<?php } ?>

меняете на:

	<?php for ($i = 0; $i < count($category['children']); $i++) { ?>
 <?php if ($i==0) { ?>
 <ul>
<?php } ELSE {?>
 <?php $j=$i-1 ?>
 <?php if ($category['children'][$i]['sort_order']<>$category['children'][$j]['sort_order']) { ?>
 </ul>
 <ul>
 <?php } ?>
  <?php } ?>
	  <?php if (isset($category['children'][$i])) { ?>
	  <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
	  <?php } ?>
 <?php if ($i==count($category['children'])) { ?>
 </ul>
<?php } ?>
	<?php } ?>

3. Важное. Суть все этого: все подкатегории с одним порядком сортировки выводятся в одну колонку.

Поэтому, на примере автора, надо сделать порядок сортировки таким:

- шины с посадочным радиусом R12 - порядок сортировки 1,

- шины с посадочным радиусом R13 - порядок сортировки 2,

- шины с посадочным радиусом R14 - порядок сортировки 3

  • +1 1
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

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.