Thread: Tree view

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0

    Tree view


    Hello! I need at fast your help.
    I have code:
    PHP Code:
      private function Display_child_nodes($parent_id$level) { 
         
          
    $parent_id $parent_id === NULL "NULL" $parent_id
          if (isset(
    $this->index[$parent_id])) { 
          
    $this->tree[] = sprintf("<div%s class='collapsable'>\n"$level == " id='folder'" ""); 
            foreach (
    $this->index[$parent_id] as $id) { 
                
    $this->tree[]  = sprintf("<span class='folder'><%s>%s</%s></span>\n"
                
    $level == "h3" "div class='file'"
                
    $this->nodes[$id]["name"], 
                
    $level == "h3" "div class='ni'" 
              
    ); 
              
    $this->display_child_nodes($id$level 1); 
            } 
            
    $this->tree[] = sprintf("</div>\n"); 
          } 

    And i want to make structure how is it:

    <ul id="browser" class="filetree treeview-famfamfam">
    <li><span class="folder">Folder 1</span>
    <ul>
    <li><span class="folder">Item 1.1</span>
    <ul>
    <li><span class="file">Item 1.1.1</span></li>
    </ul>
    </li>
    <li><span class="folder">Folder 2</span>
    <ul>
    <li><span class="folder">Subfolder 2.1</span>
    <ul id="folder21">
    <li><span class="file">File 2.1.1</span></li>
    <li><span class="file">File 2.1.2</span></li>
    </ul>
    </li>
    <li><span class="folder">Subfolder 2.2</span>
    <ul>
    <li><span class="file">File 2.2.1</span></li>
    <li><span class="file">File 2.2.2</span></li>
    </ul>
    </li>
    </ul>
    </li>
    <li class="closed"><span class="folder">Folder 3 (closed at start)</span>
    <ul>
    <li><span class="file">File 3.1</span></li>
    </ul>
    </li>
    <li><span class="file">File 4</span></li>
    </ul>
    </li>
    </ul>


    Can you help me, thank you very much
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,245
    Rep Power
    9400
    Question 1: What does the current version output?
    Question 2: How does it compare with the version you want?
    Question 3: What kinds of changes does it need to match?
    Question 4: Where would those changes be in the code?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0
    I showed my code, and it must change.
    Now i changes it on:

    PHP Code:
       private function Display_child_nodes($parent_id$level) {
        
          
    $parent_id $parent_id === NULL "NULL" $parent_id;
          if (isset(
    $this->index[$parent_id])) {
          
    $this->tree[] = sprintf("<li class='collapsable'>%s"$level == " id='folder'" "<ul>");
            foreach (
    $this->index[$parent_id] as $id) {
                
    $this->tree[]  = sprintf("<span class='folder'><li><%s></li>%s</%s></span>",
                
    $level == "h3" "span class='file'",
                
    $this->nodes[$id]["name"],
                
    $level == "h3" "li class='ni'"
              
    );
              
    $this->display_child_nodes($id$level 1);
            }
            
    $this->tree[] = sprintf("</li>");
          }

    I use jqury plugin Treeview for build html structure, that generate at php
    http://max-at-work.narod.ru/jquery.tree.test.html
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0
    Can help me please someone?
  8. #5
  9. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,245
    Rep Power
    9400
    What's the problem? It looked like you answered your own question.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0
    I gave only not completed code, it not that i need. Look please at link and my php, i want to output HTML tree
  12. #7
  13. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,245
    Rep Power
    9400
    I gathered as much. How close does your current code get? What does it output so we can compare that to what you need?

IMN logo majestic logo threadwatch logo seochat tools logo