Hi! I'm trying to create a menu listing my pages
With my limited PHP knowledge, I tried:
[code]
<?php
foreach (getPages(TRUE) as $page) {
printPageLinkURL( $page );
echo "\n";
}
?>
[/code]
but the result was:
[code]
/zenphoto/pages/Array
[/code]
repeated for as many pages as I have.
Not cool.
Basically, I'd like to know how to (or some pointers on where I could get the information) iterate through the list of pages and grab their respective URLs and depths.
Before you go and tell me I should just use printPageMenu(), I'd better tell you that there isn't an option on the "option" parameter that allows me to create a menu of the kind I'm looking for.
Thanks (in advance) for your help
Comments
But are you doing this at all? There is already a function for Zenpage pages menus called "printPageMenu()" (sic!) with lots of options. You should have noticed that when looking at the standard Zenpage theme.
Also there is a menu manager plugin to create custom menus using mixed items.
By your answer here, it looks like you've just skimmed over my question. I realise you might not have much time, but I've extracted the problematic section:
`
Before you go and tell me I should just use printPageMenu(), I'd better tell you that there isn't an option on the "option" parameter that allows me to create a menu of the kind I'm looking for.'
`
It doesn't allow the type of menu that I want, according to this page: http://www.zenphoto.org/documentation/plugins/zenpage/_zp-extensions---zenpage---zenpage-template-functions.php.html
Quote:
`
The mode for the menu: "list" context sensitive toplevel plus sublevel pages, "list-top" only top level pages, "omit-top" only sub level pages "list-sub" lists only the current pages direct offspring
`
There we go. There seems to be no option to allow the showing of subpages when a top-level page has been clicked, which is what I am looking for.
I saw that (the menu manager plugin), and as far as I can work out, you cannot create menus dynamically, using the pages as menu items? I don't want to have to add the page to the menu every time I add one.
Do you know how/where I can find the information to figure out how to iterate over the list of pages and extract their URLs and depths?
To the page option. Of course there is an option that shows sublevels if the/a toplevel is clicked. That is "context sensitive" so the "list" mode is the way to use. Why don't you just try around at little to see what which option does first?
Regarding the menu manager you can call for example the printPageMenu function as an menu item itself. (menu item type "php functions" or so). Use the Zenpage theme and enable the menu manager and it should create such a menu with all item types automatically.
If you for some reason really need to build your own menu (those cases may exist of course) you need to look at the code of our menu functions. Such a menu is not an as easy task as you might think if you want it as a valid nested html list which is menu by standard should be. This is what our functions create. This is nothing for someone with "limited php knowledge" as you described yourself.
I don't know if it is possible to achieve that with the "list" option, and hence, I jump straight to coding, which I would like to think I'm decent at. Coding (generally) has the same concept in most languages, hence I was hoping I could pick up PHP rather quickly, having a decent C++ background.
Thanks for your help so far
Hopefully you're right, and it's already built it via the "list" option, and I am blinded by my piano-playing greatness
I'm sorry if I seemed a little rude in the last message, it was simply because I felt you assumed that I didn't check the documentation and didn't look at the standard theme, both of which I did first. I always, without fail, try to do something myself before asking a question. I apologise.
What you wish to do will require the menu_manager and a custom menu (or a custom function of course). That is because you need a menu that folds out dynamically without page reload using JavaScript. Technically this would be a nested list that actually is always folded out while the js determines the hiding and showing of the levels. All our menu functions fold out as said context sensitive but on page reload. So only the foldout based on the context (=current page loaded) is generated.
Adding the custom CSS classes needed like in your example is only possible using the menu manager conveniently. (How much pages do you plan to add every day that using this is such an issue?).
Then you would have to use the "list" mode and setting the $showsubs parameter to a high value so you always get a list with all sublevels.
Btw, I suggest to look at newer examples and for jQuery framework solutions (that is on board) which is much easier most of the time.
Thanks for your help. I will try and code my own function, and if I fail epically, I will use the menu manager. One last question before I go: Can I figure out if a page has any children? If so, that'd save me a LOT of pain
Anyway, as said for a custom function you should look at code of the existing functions, in case of the pages that is the printNestedMenu() function which is used for pages and news categories.
I'll study that file in a bit more detail tomorrow When I finish my function, I might post it here for others to use, if they want