Jump to content

Recommended Posts

Всем добрый день. Бьюсь над выводом категорий, хочу сделать меню аккордеон. Есть такой код:

Спойлер
<div id="accordion">
 <div class="panel list-group">
 <?php foreach ($categories as $category) { ?> 
 <?php if ($category['children']) { ?> 
 <?php if ($category['category_id'] == $category_id) { ?> 
 <a class="list-group-item panel-heading active" data-toggle="collapse" data-parent="#accordion" href="#<?php echo $category['category_id']; ?>"><?php echo $category['name']; ?><i class="indicator glyphicon glyphicon-triangle-bottom pull-right"></i></a>
 <?php } else { ?> 
 <a class="list-group-item panel-heading" data-toggle="collapse" data-parent = "#accordion" href="#<?php echo $category['category_id']; ?>">
 <?php echo $category['name']; ?><i class="indicator glyphicon glyphicon-triangle-bottom pull-right"></i></a> 
 <?php } ?> 
 <div id="<?php echo $category['category_id']; ?>" class = "panel-collapse collapse">
 <?php foreach ($category['children'] as $child) { ?> <?php if ($child['category_id'] == $child_id) { ?>
 <a href="<?php echo $child['href']; ?>" id="accordion-body" class="list-group-item active">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a> <?php } else { ?> <a href="<?php echo $child['href']; ?>" id="accordion-body" class="list-group-item">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a> 
 <?php } ?> <?php } ?> 
 <a href="<?php echo $category['href']; ?>" class="list-group-item">Все <?php echo $category['name']; ?></a> 
 </div> 
 <?php } else { ?> <?php if ($category['category_id'] == $category_id) { ?>
 <a href="<?php echo $category['href']; ?>" class="list-group-item active"><?php echo $category['name']; ?></a> 
 <?php } else { ?> 
 <a href="<?php echo $category['href']; ?>" class="list-group-item"><?php echo $category['name']; ?></a>
 <?php } ?> 
 <?php } ?> 
 <?php } ?> 
 </div>
 
  <script> function toggleTriangle(e) { $(e.target) .prev('.panel-heading') .find("i.indicator") .toggleClass('glyphicon-triangle-bottom glyphicon-triangle-top'); } $('#accordion').on('hidden.bs.collapse', toggleTriangle); $('#accordion').on('shown.bs.collapse', toggleTriangle); </script>

 

Он работает на 99% правильно. Никак не могу понять, что нужно докрутить, чтобы при переходе в подкатегорию главная категория оставалась раскрытой, а не закрытой, как сейчас. 

Подскажите, пожалуйста, где докрутить.

В картинках:

Спойлер

1111111.jpg.6fb959dbffee81f21dc08f9f832cc317.jpg

Спасибо!!!

Share this post


Link to post
Share on other sites

Добрый день

 

 

Модуль сохраняет развертку в категориях

Share this post


Link to post
Share on other sites
8 часов назад, tsolutions сказал:

Добрый день

 

 

Модуль сохраняет развертку в категориях

Сможете доделай мой код? Можно в ЛС цену?

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.


  • 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.