Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6903471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:55:47+00:00 2026-05-27T07:55:47+00:00

hello i am trying to create a tree like menu (kind of like the

  • 0

hello i am trying to create a tree like menu (kind of like the file explorer in windows)

i have created the “tree” view using

    <ul> and <li>

but i dont know how to create the part that is expands and collapses like the file explorer

this is the loop that creates the my tree

        for($i=0, $n=count($cats); $i<$n; $i++){
            if($levels[$cats[$i]->level] == 0)
            {
                $tmp_html .= '<ul>';
                $levels[$cats[$i]->level] = 1;
            }
            $tmp_html .= '<a href="index.php/component/users/?view=students&links=4&s='.$cats[$i]->value.'">';
            $tmp_html .= '<li>'.$cats[$i]->text.'</li>';
            $tmp_html .= '</a>';
            if(($i<$n-1)&&($cats[$i]->level>$cats[$i+1]->level)){
                $tmp_level = $cats[$i]->level - $cats[$i+1]->level;
                for($j=0; $j<$tmp_level; $j++){
                    $tmp_html .= '</ul>';
                    $levels[$cats[$i-$j]->level] = 0;
                }
            }
        }

how would give it the tree like action?

thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:55:48+00:00Added an answer on May 27, 2026 at 7:55 am

    You made the structure of your treeview, but you need to define the style of it or how it would be displayed on the page, and this is the job of CSS, so you just need to play around with Css, first you have to give your ul and li ids like :

    <ul class="TreeView" id="TreeView">
      <li class="Collapsed"> First level 1 node
          <!-- level 2 nodes -->
          <ul>
             <li>First level 2 node</li>
             <li>Second level 2 node</li>
          </ul>
       </li>
    </ul>
    

    Then add the following style that makes your lists as you want:

    .TreeView LI
    {
      padding: 0 0 0 18px;
      float: left;
      width: 100%;
      list-style: none;
    }  
    LI.Expanded
    {
       //
    }
    LI.Expanded ul
    {
       display: block;
    }
    LI.Collapsed
    {
       //
    }
    LI.Collapsed ul
    {
       display: none;
    } 
    

    This example is just a simple two levels treeview the point is the Display property which makes the sub level visible :Block or collabsed :none.
    This is just Simple CSS Based Treeview.
    If you searched the web a little bit, you will find alot of tutorials on how to implement advanced treeviews with Css, JavaScript and jQuery like This.

    Hope this will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys i am trying to create a folder using c# mvc3. I have
Hello I am trying to create an animation like creating heart like bubbles but
Hello I'm trying to create grouping in the pdf file and I have to
Hello I am trying to create a war file in netbeans7.0 but I am
Hello I am trying to create a custom expandable listview, but the documentation on
I'm trying to create an Hello World JSF application. I have a bean with
I'm trying to create a POST request using angular.js to this Django view. class
Hello I am trying to create a stacked barplot using the following code: test
hello everyone im trying to create this tweak that copies a file from one
Hello I am trying to create some simple pagination, but my php skills are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.