Quick’n’Dirty PHP Script: URL Menus

 

I figured it was hight time to give a little back to society, and make up for all that money I’ve been stealing from the donation box in the buddhist temple next-door.

So, here is something useful for a change.

Well, the usefulness of this script is rather limited if you do not operate your own website onto which you regularly place new content… but hey, I’m sure it can find its public.

I was inspired by this guy (website worth a check: the rants get old quick, but some of the pictures just embody japanese freakiness) and his moaning that he could not manage to code a bunch of drop-down menus that let you jump to each topic directly.

This is simply what this PHP script does: write down the name, URL, category and date of each of your page in a simple text file and, each time the page is displayed, it will parse the file, organize the content in different menus, by date, by category etc.

simple. easy. somewhat useful (provided you are set on not using any of these easy-to-use ready-made blog&bbs systems out there).

You can download it here.

To install it, you just need to drop the files on your webserver (provided it has PHP support, of course). Here is a brief description of what does what:

  • side.php: the only essential file here, this is the code for the frame that contain all the menus… if you are used to play with HTML and can work around PHP, feel free to change its layout to fit your needs (colors can be changed separately through the css file, see below).
  • styles.css: controls most of the styles for the sidebar. This is the only file you need to edit if you wanna modify the way the bar looks (colors, fonts etc)
  • data.txt: that’s where you put your list of pages. Basically, it must be a text file containing a list (one per line) of pages you want to see in the menu. Check out the example for details.
  • The rest you barely need:

  • index.html: is just a frame to hold the sidebar and the main page (where each page is loaded). Feel free to change the layout and size, but keep the frame’s name.
  • intro_page.html: is the page that will be loaded first by index.html. Replace it by whatever you want.

And because I consider that even my most ridiculously small 30-line projects are worthy of trendy militant-geek labels: the whole thing is released under Creative Commons GPL 2 license, which means you can do pretty much whatever you want with it, except claim your grandma made it or sell it to IBM for a million bucks.

Share and Enjoy!

Filed under: Geek

1 comment

  1. Have you tried hooking this up a database/managing this via some sort of Nested Set type navigation? IMHO I think that would be more appropriate than using a text file.

Comments are closed.