The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Tree view
Discuss Tree view in the PHP Development forum on Dev Shed. Tree view PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 22nd, 2013, 01:17 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 14
Time spent in forums: 4 h 20 m 7 sec
Reputation 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 == 0 ? " id='folder'" : "");
foreach ($this->index[$parent_id] as $id) {
$this->tree[] = sprintf("<span class='folder'><%s>%s</%s></span>\n",
$level == 0 ? "h3" : "div class='file'",
$this->nodes[$id]["name"],
$level == 0 ? "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
|

January 22nd, 2013, 01:49 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
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?
|

January 22nd, 2013, 01:58 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 14
Time spent in forums: 4 h 20 m 7 sec
Reputation 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 == 0 ? " id='folder'" : "<ul>");
foreach ($this->index[$parent_id] as $id) {
$this->tree[] = sprintf("<span class='folder'><li><%s></li>%s</%s></span>",
$level == 0 ? "h3" : "span class='file'",
$this->nodes[$id]["name"],
$level == 0 ? "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
|

January 30th, 2013, 04:41 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 14
Time spent in forums: 4 h 20 m 7 sec
Reputation Power: 0
|
|
|
Can help me please someone?
|

January 30th, 2013, 05:34 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
What's the problem? It looked like you answered your own question.
|

January 31st, 2013, 03:12 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 14
Time spent in forums: 4 h 20 m 7 sec
Reputation 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
|

January 31st, 2013, 03:29 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
I gathered as much. How close does your current code get? What does it output so we can compare that to what you need?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|