PHP Developers Network
http://forums.devnetwork.net/

Multilevel Navigation from files and folders
http://forums.devnetwork.net/viewtopic.php?f=1&t=144721
Page 1 of 1

Author:  ApheX87 [ Wed Nov 22, 2017 9:02 am ]
Post subject:  Multilevel Navigation from files and folders

Hello Community,

ive just signed up and this is my first post in here, so dont bare with me if im in the wrong subforum please.
I came here because i stuck in a problem that confuses me so much that im just unable to solve it on my own...

i need to create an self-building navigation from directorys, my current folder-structure looks like this:

[Main Folder] Modules:
- [Folder] Tools
- - [Subfolder] Tool One
- - - index.php
- - [Subfolder] Tool Two
- - - index.php
- [Folder] Projects
- - [Subfolder] Project One
- - - [Sub(Sub)folder] Project Tool One
- - - - index.php
- - - [Sub(Sub)folder] Project Tool Two
- - - - index.php
- - - [Sub(Sub)folder] Project Tool Three
- - - - index.php
- - [Subfolder] Project Two
- - - [Sub(Sub)folder] Project Tool
- - - - index.php

it should be possible to randomly add directorys with files anywhere inside the Modules folder and the script checks on his own whats new, where it belongs, how its named and add it to the navigation.

like:

Syntax: [ Download ] [ Hide ]
<ul>
  <li>tools
    <ul>
      <li><a href="/index.from.path">Tool One (basicly the folders name on all examples here)</a></li>
      <li><a href="/index.from.path">Tool Two</a></li>
    </ul>
  </li>
  <li>Projects
    <ul>
      <li>Project One
        <ul>
          <li><a href="/index.from.path">Project Tool One</a></li>
          <li><a href="/index.from.path">Project Tool Two</a></li>
          <li><a href="/index.from.path">Project Tool Three</a></li>
        </ul>
      </li>
      <li>Project Two
        <ul>
          <li><a href="/index.from.path">Project Tool</a></li>
        </ul>
      </li>
    </ul>
  </li>
</ul>
 


is something even possible or cant i just dont see the forrest between all those trees?

i hope some of you are able to help me here.

best thanks and greetings from germany

- sorry for my bad english :S

Author:  requinix [ Wed Nov 22, 2017 9:30 am ]
Post subject:  Re: Multilevel Navigation from files and folders

Are you able to make a function that creates one simple <ul> for a given directory? Like
Syntax: [ Download ] [ Hide ]
function print_navigation($directory, $urlroot = "") {
        echo "<ul>";
        /* print items in $directory */
        echo "</ul>";
}

$directory is the path to use and $urlroot is the URL prefix for the directory - like Tool One's index.php would be $urlroot = "/Modules/Tools/Tool One" (or something similar).

If that function is written then it's easy to make it recursive: it calls itself to print subdirectories as it comes across them.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/