One of the first things I noticed when beginning to use Pagelime is that many users were begging for deeper level navigation and multiple menus. Me too. But I figured out how to do it. The three files I am providing here show my progress toward a very robust PHP version that I now use, to which you can pretty much do anything you want, and then some.
===================
First of all, the default Pagelime Navigataion File Code only allowed me to go two levels deep: a main menu and a sub menu. This was not adequate for my needs so I created this...
http://www.deenfoxx.com/pagelime/basic-navigation-file-code.txt
This simple script will grab all levels of navigation, but I didn't put CSS classes in. This only shows you the skeleton for what comes next.
====================
I included the basic version only because others may want to build on that base and not try to decipher this...
http://www.deenfoxx.com/pagelime/advanced-navigation-file-code.txt
This advanced script will grab all levels of navigation, provide extensive classing for CSS and give a nice clean HTML output for perfectionists like myself.
Item classes in the output include...
-------------------------------------
In the UL tags classes: is_level_{level #}
In the LI tags classes: is_level_{level #}, is_parent, of_{# of children}, is_first_item, and is_last_item
Each menu item is also given a sequential id #...
-------------------------------------------------
For the LI tags ID: item_{id #}
For the A tags ID: link_{id #}
====================
Even that was not enough for me, though, because I needed multiple menus (main, bottom, side) and special options (such as icon images, color, etc.), as do many of you. So, I came up with this monstrosity...
http://www.deenfoxx.com/pagelime/php-navigation-file-code.txt
The top part is the Velocity coding which puts everything into a flat PHP array. The array elements include the following keys...
this_id, title, url, level, and parent_id
"this_id" is a self-referencing ID of the array key (the unique sequential id of the menu item), which comes in handy sometimes. The rest of the keys are pretty self-explanatory.
====================
Now we get complicated. The bottom part is the PHP ONLY code that parses parameters off the end of url's that you have provided in the Navigation Manager. Since it is PHP only, you don't have to include it in the Navigation Manager's Navigation File Code--but it doesn't hurt either.
Here is what I've done. No URL should have spaces, BUT PageLime is nice enough to allow them in your menu items URL when you add/edit. So, anything my code finds after a space is considered part of a parameter. BUT....
(1) Parameters are in the form of "key=value" (without the quotes). There must not be spaces between the key name and equal sign. When parsed, the key name and its value will be added to the flat array.
(2a) If you fail to include a "key=", it will assume you wanted it appended to the previous key. This will allow you to have spaces in your key values. So, "page1.html tool_tip=This is a menu-item tooltip" will work as expected without using quotes.
(2b) This has a unique side-effect: "page1.html this=first that=second this=third" will result in the value for 'this' to be 'first third".
(3a) But, we never want to append to the special keys ('this_id','title','url','level', and 'parent_id'), so if we attempt to append to those, or use those key names, it will create an array of values instead (appending a '_array' to the end of the key name) without affecting the original value. (You can also add your own keys to the $special_keys_array list, if you wish).
(3b) The best use of this is multiple urls, you can simply enter multiple urls in a row separated by spaces without ever having to specify a key. Meaning: "page1.html page2.html page3.html" is the same as "page1.html url=page2.html url=page3.html". You will end up with them all in an array with the key "url_array", including the original one.
(4) I even accounted for the potential of query strings. So, if my parser sees "page1.html?this=that", it will NOT make "page1.html?this" into a key with "that" as a value. It will assume it is a URL because it sees a "." and a "?" before the "=". NOTE: Query strings are NOT parsed, they remain attached to the URL.
(5) I even put in special handlers for turning special characters into their html entities equivalent. This also prevents executing PHP code by directly putting it into your menu urls (this would be a big security risk). If you want to be able to execute php code provided on the URL, you will have to write your own procedures using eval() [NOT SUGGESTED].
(6) After everything has been parsed, your "url" key will only contain the portion of the "url" before any spaces. You'll have to play with it a bit to really see what's going on. That is why I left in the $debug option.
====================
As if that wasn't enough. The last part splits up the newly created and parsed $nav_item array into multiple $menu_item arrays and their corresponding $menu_info.
(1) If you leave this code in, it will create new arrays ($menu_item and $menu_info), but it will leave the parsed $nav_item array alone. If you know you won't need multiple menus, though, you should remove this part of the code since it will be a waste of processing.
(2) To use it, it simply sees the root items (in level 1 of your navigation) as individual menus. The URL you enter will be the menu's name. Optionally, if you want to use the URL for, well, a URL, then you can pass the parameter menu={menu name} instead.
(3) The resulting $menu_item array holds the arrays of menu items. This is the same as it is in the $nav_item array, but requires the menu name to be the first array key. So, for example: $nav_item[2]['title'] might now be $menu_item['top'][2]['title'].
(4a) The resulting $menu_info array holds ARRAYS of ARRAYS of your menu info (this_id, title, url, level). 'parent_id' should always be 0.
(4b) Note that even $menu_info is an array of arrays. This is JUST IN CASE, you decide you want to split up a single menu into different level 1 sections. All the menu items will be under the same menu id, but there will be two different menu parent ids. If you only have one menu name for each menu, it will always have an index of zero (0)... For example" $menu_info['main'][0]['title']. Additional level 1 items with the same name will end up as index 1, 2, 3, ...
====================
Do as you wish with it (open source, heh). I ended up needing the php version for my needs. The other two were just progress toward it. Everything has been tested as functional such that you could just copy/paste and go. HOWEVER, I do not do any validations of any parameters aside from converting to html entities, and you can not hold me responsible for damage caused by any errors in my code. If you find anything, I would be appreciative if you could let me know.
Best Wishes,
Deen Foxx