WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Fold Page List plugin

[Resolved] Fold Page List plugin

Viewing 15 replies - 1 through 15 (of 16 total)
  • * bump *

    here’s the code fragment I’m using…it should apply to wp_list_pages() as well:

    <?php
            $thispage = $wp_query->post;
    
            if ($thispage->post_parent!=0)
            {
                wswwpx_fold_page_list("title_li=&child_of=".$thispage->post_parent);
            }
            else
            {
                wswwpx_fold_page_list("title_li=&child_of=".$thispage->ID);
            } ?>

    What can I add to this to ensure that when I go to a sub-child, I get the child page above it listed as well?

    Marked as resolved because I’m going to take a different tack on this one.

    Hi,

    I am having exactly the same problem, what was your final solution?

    Hi,

    The problem with the above code fragment is that it only handles the case children of the current page or children of its parent… If the page list you are trying to generate is more than one generation above the current page, then it simply won’t work.

    The Fold Page List plugin includes an internal function (_wswwpx_page_get_ancestor_ids) to return the entire ancestral tree as an array, from the root of the site to the current page (the order can also be reversed), allowing you to always get the id for any page ancestor. Simply feed it the id of the current page, and then select the id you need from the output array to get the navigation you require. For example, if $pageID is the current page located at the 4th level, then its grand-parent will be at the second position in the array of ancestors.

    $ancestors = _wswwpx_page_get_ancestor_ids($pageID);
    $grandParent = $ancestors[1];
    wswwpx_fold_page_list("title_li=&child_of=".$grandParent);

    Should do the trick.

    Cheers

    Rob

    Hi,

    I’ve just posted an explanation of how to build multi-level page navigation lists which goes into a little more detail than above.

    Cheers

    Rob

    Hi. I’ve installed Foldpages and works great. I have a question about the order though. Above it was mentioned you can “reverse” the order. Right now, my child cats that run 1-6 in WordPress order are showing up reversed on my site. So #6 first, then down to #1. Is there a simple solution?

    There is an error on my part where it says “my child cats” – I meant “child pages” – not categories. Also, when I get a resolution to this I’ll post elsewhere – didn’t mean to post in resolved topic.

    roblgs: where is the description. it shows the empty page instead of how to build multi-level page navigation lists
    thanks.

    Hi folks,

    I’ve been in contact with Rob via email, I don’t think he has seen this page updated yet so I’ll post my solution in the meantime.

    This will give you a multi level page navigation list right to the root of your site:

    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $grandParent = $ancestorIDs[0];
    wswwpx_fold_page_list("title_li=<h2>Navigation</h2>&sort_column=menu_order&child_of=".$grandParent);

    …and this will give you your top level and everything underneath seperately:

    // Top level navigation
    wswwpx_fold_page_list ('depth=1&sort_column=menu_order&title_li=<h2>Top Navigation</h2>');
    
    // Sub level navigation
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $grandParent = $ancestorIDs[1];
    wswwpx_fold_page_list("title_li=<h2>Sub Navigation</h2>&sort_column=menu_order&child_of=".$grandParent);

    Hope that helps 🙂

    Cheers,
    Robert

    Hi!

    I’ve got a problem, my PHP-skills isn’t that well, but is it possible to get a horizontal menu like this with the Fold Page List Plugin?

    @rsimpson – thanks for explaining a little further, it’s helped out quite a bit.

    @rsimpson – that is very helpful, thank you!

    My question is this, I have an About Page. I have 2 children under the About Page. Under each child, I have 3 grandchildren pages.

    What I am trying to do is show the following Navigation structure:

    About
    -Child 1
    --Gchild 1.1
    --Gchild 1.2
    --Gchild 1.3
    -Child 2
    --Gchild 2.1
    --Gchild 2.2
    --Gchild 2.3

    I am trying to get it to show this full structure, no matter which page on the chain you are at. I can get it to show the full structure okay, but it includes ALL pages in the WordPress system. Is there a way to limit the list to ONLY include pages that fall under the About Page? (i.e. maybe with $grandParent = $ancestorIDs[1]; somehow)

    @rsimpson – legend! That is exactly what I have been looking for.

    @maestro42 – I have been trying to get the same nav structure. I modified RSimpson’s code sample as follows:

    <!-- Sub level navigation-->
    <!-- This first bit does the Title entry eg "About"-->
    <li>
    <ul>
    <h2><?php
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $titlePage = $ancestorIDs[1];
    wp_list_pages("title_li=&depth=1&include=".$titlePage);
    ?></h2>
    <!-- Then this bit does the other pages-->
    <?php
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $grandParent = $ancestorIDs[1];
    wswwpx_fold_page_list("sort_column=menu_order&child_of=".$grandParent);
    ?>
    </ul>
    </li>

    Used in conjunction with the modification to the plugin outlined by DoodleBee here this should give you what you are looking for. Note: this is dirty hack job so I won’t guarantee it’s even close to the best way to do this. If anyone wants to suggest a more elegant solution please feel free 🙂

    Apologies – a little premature there… This code snippet, used in conjunction with the Doodlebee rewrite, gives you a full chain of links when on a page in the chain, and nothing when on any other page.

    <!-- Sub level navigation-->
    <?php
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $titlePage = $ancestorIDs[1];
    $childIDs = _wswwpx_page_get_child_ids($titlePage);
    if (is_array($childIDs))
    {
    ?><li><ul><h2><?php
    wp_list_pages("title_li=&depth=1&include=".$titlePage);
    ?></h2><?php
    $grandParent = $ancestorIDs[1];
    wswwpx_fold_page_list("sort_column=menu_order&child_of=".$grandParent);
    ?></ul></li><?php
    }
    ?>

    thanks! I will take a look at this and see what I can come up with.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Resolved] Fold Page List plugin’ is closed to new replies.