WordPress.org

Support

Support » Plugins and Hacks » Foldable page list (WP 1.5)

Foldable page list (WP 1.5)

  • I have a plugin that will automatically expand only the sub-pages of the currently selected page in a page list, collapsing all others to their parent page. Expansion reveals one level deeper than the currently selected page, down to a maximum level determined by the value of the ‘level’ argument.

    So, for a hierarchy consisting of:

    Fruit
    – Apples
    — Red
    — Green
    – Pears
    — Soft
    — Hard
    Vegetables
    – Beans
    — Runner beans
    — Broad beans
    – Greens
    — Cabbage
    — Lettuce

    With nothing selected and level=3, it would show as:

    Fruit
    Vegetables

    Selecting Fruit would show:

    Fruit
    – Apples
    – Pears
    Vegetables

    Selecting Apples would reveal

    Fruit
    – Apples
    — Red
    — Green
    – Oranges
    Vegetables

    Selecting Vegetables would reveal

    Fruit
    Vegetables
    – Beans
    – Greens

    etc…

    It should retain all functionality of the standard wp_list_pages plugin since it is implemented as merely a modified (& renamed) version of that tag, but adds the selective unfolding of the page hierarchy. Syntax is identical to its precursor tag.

    A page explaining installation and use, and a link to a downloadable zip archive is available at http://www.webspaceworks.com/wp-plugins/foldpagelist.html.

    I hope others might find it useful, and welcome any feedback.

Viewing 15 replies - 1 through 15 (of 43 total)
  • I clicked on your link, but got an error message. Is there another link where I can access this plug-in? Thanks!

    Apologies… I seem unable to now edit the post, but vkaryl has posted the correct link. Thanks

    Welcome, and it’s a nifty thing – got some thoughts about how to use it….

    Downloaded and uploaded onto my server successfully. How can I collapse the pages that I have listed and will post in the future?

    How were you doing this (listing them) previously? The plugin is, in many ways, a replacement for wp_list_pages, so whatever worked with that should, I think, work with this… yours though is one scenario that hasn’t been tested for, and I hadn’t in fact even considered.

    Do you mean pages that are within your hierarchy, but for which there is no content yet?? Can you explain a little more?

    What I’ve been doing is creating a blank page for the parent categories, and then individual pages for each of my articles. To get an idea, visit my site at http://thewritersbuzz.com.

    OK, so at which point do you wish to collapse to… or is it more a question of excluding parent pages for which there are no children?

    If it is more driven by ‘the page exists, but the article not yet written’, then it becomes content related (rather than structure) and outside the scope of this plugin… at least in its current form.

    I’d like though to understand further, but it seems as if your implementation through pages is somewhat duplicating behaviour that might more easily be provided through the categories/posts mechanism of the blog side of things… including future posting…. Not a criticism, just an observation.

    What I’d like to do is keep the parent pages in view, collapsing the child pages so the sidebar will look less cluttered. Ideally, all the user would need to do is click on the parent page to display the child pages. But, I’m thinking that I won’t be allowed to do this at all.

    The way I have things set up now is that I have a blank page that displays the title of each of the parent categories I created (i.e., Blogging, Media & PR, Internet Marketing, etc.). When I create a new page for an article, I categorize it as a child page for the relevant parent page.

    “but it seems as if your implementation through pages is somewhat duplicating behaviour that might more easily be provided through the categories/posts mechanism of the blog side of things… including future posting…. Not a criticism, just an observation.”

    That’s exactly what I did. I wasn’t clear on how to create subpages in any other way. I tried reading the Codex but got more confused.

    The first para is exactly what fold page list is meant to do, but clicking one of the parent pages will load that page, and expand that part of the page list, but the page itself is empty, which feels odd.

    Fold page list works off the current request id, in this case the id of the currently loaded page, to determine what gets compressed/expanded. Fold page list does not expand/contract in-place since it is not javascript based, which sounds more like what you are looking for.

    One way around this might be to have it such that the parent pages act as an introduction to that section/group of articles… at least that would get away from the empty page scenario, but with a tidier page list on each load.

    Does that make sense?

    Yes, it does. I could implement a table of contents on the parent pages. I’ll have to read up on the Codex again to determine how not to display the child pages. Thanks for your help. 🙂

    Probably in sidebar.php of your theme, wherever you are calling wp_list_pages, you could add ‘&level=1’ to the end of your arguments list… or ‘?level=1’ if you don’t currently use any arguments.

    Alternatively, using the fold page list plugin, use the following:

    wswwpx_fold_page_list (‘?level=2’);

    in place of wp_list_pages. The value of 2 means ‘parents and children as far as 1st generation’… but the expansion will only be on the currently selected parent, all others should collapse.

    hmm when i try the above i get a error.

    Fatal error: Call to undefined function: _wswwpx_() in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/fold_page_list.php on line 170

    i have this in my themes sidebar.php
    <?php wswwpx_fold_page_list (‘?level=2’); ?>

    any clues ? i also tried with my (args) from the wp_list_pages with no luck … running WP 1.5

    Oops!

    Thanks for pointing this out. An embarassing ‘cut-n-paste’ introduced bug that wasn’t being trapped in my testing… now fixed.

    Download fold_page_list v1.0b2 here.

    Also, my reference to:

    wswwpx_fold_page_list (‘?level=2’);

    should read:

    wswwpx_fold_page_list (‘?depth=2’);

    But shouldn’t have contributed to the problem you encountered.

    Whipes egg from face!

    Let me know if that fixes it for you.

Viewing 15 replies - 1 through 15 (of 43 total)
  • The topic ‘Foldable page list (WP 1.5)’ is closed to new replies.