Jump to content
Sign in to follow this  
Vasyanya

Автоматически рыскрывающиеся категории

Recommended Posts

Доброго суток!

Интересует следующее.

При наведении курсора на категорию автоматически раскрывались подкатегории.

Opencart 1.5.6.4

vqmod

шаблон 

 

можно без модулей это сделать?

Share this post


Link to post
Share on other sites

Вот что нашел.

В bootstrap есть функция dropdown-menu 

http://bootstrap-3.ru/components.php

Осталось это теперь прикрутить к категории 

<div class="box category">
	<!--<div class="box-heading"><?php echo $heading_title; ?></div>-->
  <div class="box-content">
  
    <div class="box-category">
      <ul>
        <?php foreach ($categories as $category) { ?>
        <?php if ($category['category_id'] == $category_id) { ?>
        <li class="active cat-header <?php if ($category['children']) { ?>parent<?php } ?>">
        <?php } else { ?>
        <li class="cat-header <?php if ($category['children']) { ?>parent<?php } ?>">
        <?php } ?>
          <?php if ($category['category_id'] == $category_id) { ?>
          <a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
          <?php } else { ?>
          <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
          <?php } ?>
          <?php if ($category['children']) { ?>

            <?php for ($i = 0; $i < count($category['children']);) { ?>
            <?php if ($category['category_id'] == $category_id) { ?>
            <ul class="active">
            <?php } else { ?>
            <ul>
            <?php }?>
              <?php $j = $i + count($category['children']); ?>
              <?php for (; $i < $j; $i++) { ?>
              <?php if (isset($category['children'][$i])) { ?>
              <?php $id=$category['children'][$i]['category_id'];?>
              <?php if ( $id == $child_id) { ?>
              <li class="active <?php if ($category['children'][$i]['children3']) {?> parent<?php } ?>">
                <?php } else { ?>
              <li class="<?php if ($category['children'][$i]['children3']) {?> parent<?php } ?>">
                <?php } ?>
                <?php if ($category['children'][$i]['children3']) {?>
                <a  href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name'];?></a>
                <?php if ( $id == $child_id) { ?>
                <ul class="active">
               	<?php } else { ?>
                <ul>
                <?php }?>
                  <?php foreach ($category['children'][$i]['children3'] as $ch3) { ?>
                  <li>
                    <?php if ($ch3['category_id'] == $ch3_id) { ?>
                    <a href="<?php echo $ch3['href']; ?>" class="active"><?php echo $ch3['name']; ?></a>
                    <?php } else { ?>
                    <a href="<?php echo $ch3['href']; ?>"><?php echo $ch3['name']; ?></a>
                    <?php } ?>
                  </li>
                  <?php } ?>
                </ul>
                <?php } else {?>
                <a  href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name'];?></a>
              <?php }?>
              </li>
              <?php } ?>
              <?php } ?>
            </ul>
            <?php } ?>
      <?php } ?>
        </li>
        <?php } ?>
      </ul>
    </div>
  </div>
</div>

 

Я так понимаю нужно менять 14, 16 строки и 22, 24.

Правильно я думаю?

Вот как-то так.

Только криво получается.

 <a TUT????? href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
          <?php } else { ?>
          <a TUT???? href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
          <?php } ?>
          <?php if ($category['children']) { ?>

            <?php for ($i = 0; $i < count($category['children']);) { ?>
            <?php if ($category['category_id'] == $category_id) { ?>
            <ul TUT???? class="active">
            <?php } else { ?>
            <ul TUT?????>

Подскажите, кто знает.

Edited by Vasyanya

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.