24th October 2000, 05:46 pm
I know that I haven’t been updating this page so often lately, but I’ve
been busy with other things. One of those things is my new menu-system.
The main requirement for the new system was, that it should be able to deal
with a tree of pages several levels deep. The new system handles this
beautifully, as you can see at the sitemap. Notice how the lists are nested
within each other. The most extreme case is at the bottom, where I use five
levels to describe the structure of my Danish Stuff.
To define this structure, I have all the pages specify their parent and
their children. All pages have a parent, but does not necessarily have any
children. I store all this information in a huge array, which means that it
is extremely easy to access the information.
Because all the pages have a reference directly to their parent, it’s quite
easy to find your way back to the root of the tree. All you have to do, is
to use a recursive function. This function takes one argument: the node
who’s parent we want to find. So the function just adds the node to a
global array, and then it calls itself with the parent as an argument.
This means that you’ll eventually reach the root, where the parent will be
an empty string (''
). It’s called recursion because we have a function
that keeps executing itself until some condition has been met. Because I
can now use recursion, the code needed to build the sitemap, has
been cut in half.
The next task, is to make some tools to make it easier for me (and
eventually also others) to maintain the structure. I’ll let you know when
it’s ready.
16th October 2000, 03:52 pm
I’ve started to rewrite my menu-system here at gimpster.com. The current
system only works when the tree-structure is two levels deep. You can see
this on my sitemap.
The new system will be able to handle an arbitrary number of levels
(remember, though, that a PHP script can only use 8 MB of RAM :-).
In the new system, all pages have a parent, and perhaps also some children.
This is what connects the different pages too one another, it defines a
tree of so-called double-linked lists. The lists are double-linked because
each node defines both the next and the previous node in the tree. This
makes it very easy to find out who the parent is to a particular node. And
to find other nodes at the same level as the current node, you just look up
the parent. Now that you know the parent, you can easily find the children
of the parent.
Thanks to the very flexible way PHP handles arrays, I can store all the
information in a huge multidimensional array. That makes it very easy to
access the information.
9th October 2000, 03:57 pm
Thanks to Eduardo Guilenea who provided me
with a translation of PHP Weather into Spanish, PHP Weather now has support for foreign languages.
So far there’s only English and Spanish, but more will hopefully come. If
you want to translate PHP Weather, then have a look at the locale_en.inc
file in the tarball. This is
the file you’ll have to translate into your chosen language.
You have to translate all the text, just remember to leave the %s
intact.
They will be replaced by the actual numbers and strings later.
I’ve also made a maillinglist for PHP Weather, so please announce it there.
To do this, just send a mail to [email protected]. If you want to
subscribe to the list, then send a mail to [email protected].