D
D
Denis Sechin2015-04-09 21:43:39
css
Denis Sechin, 2015-04-09 21:43:39

How to combine 2 site menus?

Hello, there is a site hollywood-salon.com.ua, it has two menus, the first: 2622d8b3cb1b4ccb8d312764961ea942.png
and the second: 763f31b4e84b4ad296dc19233295af11.png
I want to combine these two menus into one, that is, add a service item to the first menu, a list consisting of a second menu will drop out of this item I know how to do it, but the problem is that the first menu is written like this:

<?php if ($categories) { ?>


<?php
  // ---------------- CUSTOM MENU ------------------	
  
  $newcats = array(
      
    array(
      'name' => 'Акции',
      'href' => '/index.php?route=information/news',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    array(
      'name' => 'Новинки',
      'href' => '/news',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    array(
      'name' => 'Прейскурант',
      'href' => '/price',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    array(
      'name' => 'Галерея',
      'href' => '/galereya',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    array(
      'name' => 'Интернет-магазин',
      'href' => '#',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    array(
      'name' => 'Подарочный сертификат',
      'href' => '/sert',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    array(
      'name' => 'Контакты',
      'href' => '/index.php?route=information/contact',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    array(
      'name' => 'Услуги',
      'href' => 'index.php?route=information/information&information_id=52',
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),
    
  );
  
  $shop_cat = &$newcats[5];
  $shop_cat['children'] = $categories;
  
  $uri = $_SERVER['REQUEST_URI'];
  //var_dump($uri);
  
  $active_set = false;
  foreach ($newcats as &$cat) {
    if ($cat['href'] == $uri) {
      $cat['active'] = true;
      $active_set = true;
      break;
    }
  }
  
  if (!$active_set) {
    $shop_cat['active'] = true;
  }
  
?>

<div id="menu">
  <ul>
    <?php foreach ($newcats as $category) { ?>
    <li><?php if ($category['active']) { ?>
  <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']) { ?>
      <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 } ?>

<?php /*

The site is not mine, they gave it to be torn to pieces, unfortunately I don’t know PHP well, how to implement my idea?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IceJOKER, 2015-04-09
@IceJOKER

THE CODE IS HORRIBLE
If you don't know your site and PHP, then why the hell are you going to change something there?
If you are a coder, feel free to tell the customer to put the code in order or pay double the price (transfer half to me and I will help you xD).
And in other cases - pay.
It is unlikely that anyone will want to parse such code, even if it is small

R
RodgerFox, 2015-04-09
@RodgerFox

Well, here is a piece from the array:

array(
      'name' => 'Услуги',
     <b> 'href' => 'index.php?route=information/information&information_id=52',</b>
      'children' => array(),
      'active' => false,
      'column' => '1',
    ),

change the link to #, add a function when clicked, open the second menu, profit. after hiding the second menu. otherwise how to "open" already "open".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question