Collapsing Pages

IMPORTANT INSTALLATION NOTES for WP 2.7
Please deactivate before upgrading, then re-activate the plugin.

The Collapsing Pages plugin creates a list of all pages and sub-pages, which can be expanded and collapsed dynamically, as you can see in the sidebar on this page. The main function is as a widget, but there is also an option to use it as a drop-down horizontal menu for basic page navigation, if you are using wordpress as a cms, as in the screenshot below:

Collapsing Pages screenshot

Note that the dropdown functionality has been removed in version 0.3, and will be made into a separate plugin in the near future.

The plugin is hosted on the official wordpress repository at: http://wordpress.org/extend/plugins/collapsing-pages

If you have any questions, bug reports, or feature requests, please go to the forum

Your appreciation

If you really like my plugins, please give them a nice ranking in the wordpress plugin repository (links above), or you can send me a donation via paypal below:

This is a very simple plugin that uses Javascript to form a collapsable set of
links in the sidebar for the pages. Every page corresponding to a given
parent page will be expanded.

It is largely based off of my Collapsing Pages and Collapsing Archives
plugins.

= What’s new?=

  • 0.6.1 (2010.06.21)

    • Removed extraneous debugging info (subpagecount=)
  • 0.6 (2010.06.18)

    • Fixed html validation bug when linkToPage is false (thanks to
      levente.csabai)
    • fixed html parsing error in widget (thanks to vbonline)’

Download

Latest version: Download Collapsing Pages v0.6.1 [zip]

Installation

IMPORTANT!
Please deactivate before upgrading, then re-activate the plugin.

MANUAL INSTALLATION
(the only option for pre 2.3 wordpress, unless you have the widget plugin installed)

Unpackage contents to wp-content/plugins/ so that the files are in
a collapsPage directory. Now enable the plugin. To use the plugin,
change the following where appropriate (most likely sidebar.php):

<ul>
 `<?php wp_list_pages(...); ?>`
</ul>

To something of the following:

<?php
  echo "<ul>\n";
      if( function_exists('collapsPage') ) {
      collapsPage();
    } else {
      wp_list_pages(...);
    }
  echo "</ul>\n";
    ?>

You can specify options if you wish. See the options section.

The above will fall back to the WP function for pages if you disable
the plugin.

WIDGET INSTALLATION

For those who have widget capabilities, (default in WordPress 2.3+), installation is easier.

Unzip contents to wp-content/plugins/ so that the files are in a
collapsing-pages directory. You must enable the Collapsing Pages plugin, then
simply go the Presentation > Widgets section and add the Collapsing Pages
Widget.

FAQ

Q. How do I change the style of the collapsing categories lists?
A. As of version 0.5.3, there are several default styles that come with
collapsing-categories. You can choose from these in the settings panel, or you
can create your own custom style. A good strategy is to choose a default, then
modify it slightly to your needs.

The following classes are used:
* collapsing – applied to all ul and li elements
* pages – applied to all ul and li elements
* list – applied to the top-level ul
* item – applied to each li which has no sub-elements
* expand – applied to a page which can be expanded (is currently
collapsed)
* collapse – applied to a page which can be collapsed (is currently
expanded)
* sym – class for the expanding / collapsing symbol

An example:

<ul id='widget-collapspage-3-collapsPageList' class='collapsing pages list'>
  <li id='about-nav' class='collapsing pages item'><a href='http://blog.robfelty.com/about/' title="About">About</a>
  </li>
<li id='donate-nav' class='collapsing pages item'><a
href='http://blog.robfelty.com/donate/' title="Donate">Donate</a>
</li> <!-- ending page subcat count = 0-->
<li class='collapsing pages '><span title="Click to collapse"
class='collapsing pages collapse' onclick='expandCollapse(event, "▶", "▼", 1,
"collapsing pages"); return false'><span class='sym'>▼</span></span><a
href='http://blog.robfelty.com/plugins/' title="Wordpress Plugins">Wordpress
Plugins</a>
     <ul id='collapsPage-67' style='display:block;'>
<li class='collapsing pages item'><a
href='http://blog.robfelty.com/plugins/collapsing-archives/' title="Collapsing
Archives">Collapsing Archives</a></li>

<li class='collapsing pages item'><a
href='http://blog.robfelty.com/plugins/collapsing-categories/'
title="Collapsing Categories">Collapsing Categories</a></li>
<li class='collapsing pages item'><a
href='http://blog.robfelty.com/plugins/collapsing-links/' title="Collapsing
Links">Collapsing Links</a></li>
<li class='collapsing pages item'><a
href='http://blog.robfelty.com/plugins/collapsing-pages/' title="Collapsing
Pages">Collapsing Pages</a></li>
<li class='collapsing pages item'><a
href='http://blog.robfelty.com/plugins/postie/' title="Postie">Postie</a></li>
      </ul><!-- subpagecount = 5 ending subpage -->
      </li><!-- subpagecount = 5 ending subpage -->
<li id='forum-nav' class='collapsing pages item'><a
href='http://blog.robfelty.com/forum/' title="WP Plugin Forum">WP Plugin
Forum</a>                  </li> <!-- ending page subcat count = 0-->
</ul>

Q. How do I make the current page prominent in the list of pages?
A. The current page has the “self” class. By default, the “self” class style is
set to bold. If you would like to change this, you can change it in the
settings page.

Changelog

0.6.1 (2010.06.21)

  • Removed extraneous debugging info (subpagecount=)

0.6 (2010.06.18)

  • Fixed html validation bug when linkToPage is false (thanks to
    levente.csabai)
  • fixed html parsing error in widget (thanks to vbonline)’

0.5.3 (2010.01.28)

  • Restricted settings page to authorized users
  • Fixed bug with manual usage
  • Fixed bug with selecting “show posts as well as pages option”
  • Fixed bug with wrong page id assigned to self class
  • Switched from scriptaculous to jquery. No longer conflicts with plugins
    which use mootools (e.g. featured content gallery)

0.5.2 (2009.07.19)

  • Added advanced options section in configuration
  • Added option to remember expanding and collapsing for each visitor
    (using cookies)
  • Now issuing a correct id for each ul when using widgets
  • Small change in manual installation

0.5.1

  • Fixed menuorder option
  • Fixed problem with multiple instances
  • Fixed problems with cookies on page load

0.5.beta

  • A few more tweaks

0.5.alpha

  • Added option to collapse widget
  • Compatible with WP 2.8 (not backwards compatible)
  • When using manually, can specify settings directly in code
  • Changed hide and show classes to collapse and expand to avoid CSS class
    conflicts
  • Tweaked default styles

0.4.3 (2009/05/06)

  • Fixed html validation error

0.4.2 (2009/04/17)

  • Fixed bug with wrong url to images
  • Fixed bug with unicode codes showing up on page load instead of triangles

0.4.1 (2009/04/16)

  • Added option for custom symbols

0.4 (2009/02/17)

  • totally revised and improved style selecting methods
  • fixed settings panel issue
  • documentation now internationalized (Bernhard Reiter)
  • german localization (Bernhard Reiter)
  • Added truncate page title option

0.3.5 (2009/02/04)

  • Updated internationalization support
  • Can now exclude and auto-expand using page slug or ID
  • Added option to make clicking on parent page expand sub-pages

0.3.4 (2009/01/21)

  • removed debugging info
  • fixed settings panel

0.3.3 (2009/01/20)

0.3.2 (2009/01/07)

  • added version to javascript file
  • not loading unnecessary code for admin pages (fixes interference with
    akismet stats page
  • ‘self’ tag now gets added in subpages

0.3.1 (2009/01/06)

  • Finally fixed disappearing widget problem when trying to add to sidebar
  • Added debugging option to show the query used and the output
  • Moved style option to options page
  • tweaked default style some

0.3 (2008.12.04)

  • can now use multiple instance of the widget
  • can also use manually
  • added option to animate expanding
  • added more options for expanding characters
  • consolidated javascript to share code with other collapsing plugins
  • moved inline javascript to footer to speed page load time
  • made styling an option (better flexibility and reduce number of http
    requests)

0.2.5 (2008.11.01)

  • fixed bug in that autoExpand was not available to getSubPage

0.2.4 (2008.10.28)

  • fixed bug with missing seventh argument to getSubPage when used recursively

0.2.3 (2008.07.14)

  • Added option to automatically expand some pages
  • Added option to control the number of levels of pages which are expanded
  • Added “self” class to pages in list which match the current page. No link
    is made for these. CSS can
    then be used to style these differently

0.2.2 (2008.05.23)

  • Re-fixed code so that xhtml validates
  • Added option for different expand and collapse icons

0.2.1 (2008.05.01)

  • Link now spans the whole dropdown
  • Now indicates the presence of an additional submenu (doesn’t work in IE 6
    or less)
  • fixed html so that it validates correctly

0.2 (2008.04.30)

  • Now includes the possibility of providing a drop-down menu of pages and
    sub-pages, instead of a nested list. Only useful for a header navigation

0.1.1 (2008.04.25)

  • Can exclude pages (and sub-pages of those pages)

0.1 (2008.04.23):

68 Responses to Collapsing Pages

  1. Hi Rob,

    I’ve got one more suggestion regarding i18n: currently, it’s not possible to exclude pages with multilanguage titles as used by qtranslate (trivially). The wordpress core Pages widget is less elegant but more flexible when it comes to excluding as it requires page IDs (not names) for its exclusion option. So maybe you’d want to switch to using page IDs, too. I think that would also enable you to use WP’s get_pages function instead of the rather complicated SQL you’re doing right now in collapsPageList.php, no? It seems to support pretty much all of the required query parameters, though you’d probably lose the ability to query for posts to include in the collapsing pages menu.

    Bernhard

  2. robfelty says:

    Bernhard. Those are some good suggestions. Thanks. One follow-up on qtranslate and i18n. Shouldn’t the slugs be the same, regardless of language? Or are there actually 2 urls pointing to the same id, like
    robfelty.com/de/hallo
    and
    robfelty.com/en/hello

    As far as the get_pages function goes, it is probably doing some complicated query itself. But it is a good idea to use the API when possible. I will have to investigate further to see if it has all the options that the plugin has.

    Rob

  3. Rob,

    you’re right about slugs, they’re the same. I was mistakenly trying to use the title instead of the slug.

    And one more note on API use: could it be that it’s actually possible to just (ab)use the plain wordpress Pages for widget by filtering the wp_list_pages() function? The wordpress widget doesn’t do much more than call that function; same for wp_list_categories() etc. Filtering those functions might make the respective collapsing widgets obsolete, which in turn could pave the way for a collapsing-*-plugin merge with just a single options page where you can configure what widgets should be displayed in a collapsible fashion, ie what wp_list_*() functions to filter… The main advantage would probably be code redundancy reduction.

    Bernhard

  4. Widget title translation:

    --- collapsPageWidget.php 2009-01-21 20:37:24.000000000 +0100
    +++ collapsPageWidget_modified.php  2009-02-04 22:14:06.000000000 +0100
    @@ -13,7 +13,7 @@
     
       $title = ($options[$number]['title'] != "") ? $options[$number]['title'] : "";
     
    -    echo $before_widget . $before_title . $title . $after_title;
    +    echo $before_widget . $before_title . __($title) . $after_title;
            if( function_exists('collapsPage') ) {
             collapsPage($number);
            } else {
  5. robfelty says:

    Bernhard,

    Thanks for all your comments and suggestions. At this point, I am not in the mood for a complete rewrite. I just don’t have time for it. It might be better in the long run. The tricky thing is that the wp_list* functions return html, so I would end up having to add a bunch of html with javascript, which is ok, but I would rather do it with php. The other thing is that different people have requested different options for the different plugins. I would still need to have a way to show different options for each use.

    I will add in your patch to the title.

    Rob

  6. Leanne says:

    Hi there :) This is a great plugin however I am having some issues. I am using a snazzy theme called Ikarus and unfortunately when I add this plugin, it kills my footer. The text still shows in the footer but it breaks all the images. I’m puzzled as to why this is, maybe you can shed some light on it as I would really like to use this plugin.
    At first, I didn’t realise it was the plugin that affected my footer until I viewed the page source and the collapsing pages code seemed to be plonked in the middle of the footer code. After disabling it, my footer worked again.

    Also, top level pages show but when I click them, nothing happens at all. It animates to show that I’ve clicked to expand/collapse but nothing happens. At some point, I managed something but I’m not too sure what I did. I think it worked when I went on to that specific parent page – then all the sub-pages showed.

    Anyway, thanks for the plugin, I just hope I can get to use it again :)

  7. Rob says:

    Leanne,

    I will check into the Ikarus theme. The plugin does load some javascript in the footer, because it speeds up page load time to put javascript at the bottom of the page. Could you send me a link to your site?

    Rob

  8. Leanne says:

    Hi Rob, thank you :) I’ve added my website in the form now.
    It seems to be an issue with the very latest version of the plugin as immediately after upgrading the plugin this issue arose.

  9. Rob says:

    @Leanne,

    Turn off the “animate collapsing and expanding” option. It is a conflict with another javascript library that your theme loads.

  10. Rob says:

    If you have any comments, questions, feature requests, or bug reports, please go to the forum

  11. Pingback: robfelty :: Blog :: Collapsing Pages Writer River

  12. Pingback: Wordpress sites and plugins I find useful | Jason-Saggers.com

  13. Pingback: Wie man statische Seiten von Business-Blogs optimal nutzt: 6 Praxistipps

  14. Pingback: robfelty com Blog Collapsing Pages | Shed Kits

  15. Pingback: 30 plugins para Wordpress | UnUsuario

  16. Pingback: Author-izer | WordPress Asylum

  17. Pingback: En iyi 40 Adet Wordpress Eklentisi indir [Ücretsiz] | www.webdunyam.net

  18. Pingback: Time to summarize plugins in QuantMinds | QuantMinds.com