zenphoto forums » Zenpage

Making a menu

(10 posts)
  1. Stew822

    Junior
    Joined: May '11
    Posts: 6

    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 :)

    Posted 2 years ago #
  2. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 14,744

    You probably should look at the documentation before starting working. The getPages() function returns an array for each page (for backwards compatibility before the objectification). So you need to call the array field "titlelink" directly

    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.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #
  3. Stew822

    Junior
    Joined: May '11
    Posts: 6

    I did read (some) of the documentation, and got confused. So using getPages() isn't the way to go?

    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?

    Posted 2 years ago #
  4. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 14,744

    getPages is certainly the function to use if you want to make your own menu. You just have to learn that it returns a mutlidimensional array.

    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.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #
  5. Stew822

    Junior
    Joined: May '11
    Posts: 6

    I did, and as far as I can work out, it isn't what I was looking for. Let me try to explain in more detail. Or, better yet, since today I don't seem to be explaining myself quite as well I possibly should be, I would like a menu such as the one in this tutorial: http://www.interspire.com/content/2005/12/07/building-an-expanding-dhtml-menu-with-css-and-javascript/

    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 :D
    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.

    Posted 2 years ago #
  6. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 14,744

    No problem. If you have C+ background you probably will get quite fast into PHP (say others as I have no C+ background..;-)).

    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.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #
  7. Stew822

    Junior
    Joined: May '11
    Posts: 6

    It's not that I'm going to be adding pages daily, or even on a regular basis, it is simply because I would like to invest in a long-term solution without any flaws. I'm fussy :)

    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 :)

    Posted 2 years ago #
  8. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 14,744

    Well, one day you will want to have a menu that also includes news categories or albums, then you will have quite some work to do. For this we made the menu manager.

    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.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #
  9. Stew822

    Junior
    Joined: May '11
    Posts: 6

    Thanks :)

    I'll study that file in a bit more detail tomorrow :D When I finish my function, I might post it here for others to use, if they want :D

    Posted 2 years ago #
  10. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 14,744

    Sure, that is always welcome. In that case I suggest best make a plugin for this right away. Please also review our contributor and developer guidelines.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.