content management system - PHP: Directory Navigation Menu -


i have question haven't been able find answer/script to. i'm learning use php. i'm using perch cms , has been going great far.

i've run snag when comes adding new pages. want php able create dynamic navigation menu directory.

for example, have 3 pages in 'about' directory.

root /about /index.php - page2.php - page3.php

i want able output side navigation menu based off directory.

home - page2 - page3

and when client/user creates new page, it'll automatically add list. so...

root /about /index.php - page2.php - page3.php - newpage.php

...creates...

home - page2 - page3 - new page

can point me direction of script or me started?

thanks!

there quite few php functions iterate through directories. think cleanest using php spl (standard php library)'s directory iterator.

http://www.php.net/manual/en/class.directoryiterator.php

$dir = new directoryiterator('about'); foreach ($dir $fileinfo) {     if (!$fileinfo->isdot()) {         // can make link here         echo $fileinfo->getfilename();     } } 

the advantage have lot of class functions available you.

if need more filename can use:

  • getpathname()
  • getpath()
  • getbasename()
  • isdir()

and on... see docs possibilities.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -