PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Dec 15, 2017 6:43 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Nov 22, 2017 9:02 am 
Offline
Forum Newbie

Joined: Wed Nov 22, 2017 8:33 am
Posts: 1
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


Top
 Profile  
 
PostPosted: Wed Nov 22, 2017 9:30 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6606
Location: WA, USA
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group