A
A
alestro2015-12-16 12:46:33
PHP
alestro, 2015-12-16 12:46:33

How to implement a similar menu using php?

c1f577807af24f569a3255d22929beb8.png
Perhaps there are some third-party libraries that implement the mega menu.
While reached only the table consisting of id. title , link , and parent , and down to the recursive method that collects the array.

public function getMegaMenuArray(){
    $sth=$this->db->prepare("select * from menu");
    $sth->execute();
    while($row=$sth->fetch(\core\Database::FETCH_ASSOC)){
      if(empty($menu[$row['parent']])){
        $menu[$row['parent']]=[];
      }
      $menu[$row['parent']][]=$row;
    }
    return $menu;
  }

But when you try to integrate it into the layout, nothing happens, and the database structure obviously does not solve all the issues.
Can you tell me how the structure of the database should be arranged. And in general, the nuances associated with this topic.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romy4, 2015-12-16
@romy4

I don't care about the database structure in this matter. You just need to copy this menu to your site and generate it correctly. There are libraries, of course. But copy-paste is always easier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question