Did you ever want to have WB remember the visibility (expanded/collapsed) state of your pages in the Admin Pages screen? For example, every time you move a page up or down, all the pages collapse, and you have to re-expand to move the page again.
Here is a simple and elegant solution, requiring a few small changes to only one file:
In /admin/pages/index.php, make the following changes:
1. Add this code before the first <script type="text/javascript" language="javascript"> tag (after the end of the first php block, around line 32):
<!-- Addition for remembering expanded state of pages -->
<script language="JavaScript">
function writeSessionCookie (cookieName, cookieValue) {
document.cookie = escape(cookieName) + "=" + escape(cookieValue) + ";";
}
</script>
<!-- End addition -->
2. Modify the Javascript function named "toggle_visibility" as follows:
function toggle_visibility(id){
if(document.getElementById(id).style.display == "block") {
document.getElementById(id).style.display = "none";
writeSessionCookie (id, "0");//Addition for remembering expanded state of pages
} else {
document.getElementById(id).style.display = "block";
writeSessionCookie (id, "1");//Addition for remembering expanded state of pages
}
}
3. Change (what was line 92 and has now become approx. line 107) from
<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list"'; } ?>>
to
<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list" '; if($_COOKIE["p".$parent] =="1"){echo'style="display:block;"'; }} ?>>
4. Change (what was line 149 and is now about line 164) from
<img src="<?php echo ADMIN_URL; ?>/images/plus_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" border="0" alt="+" />
to
<img src="<?php echo ADMIN_URL; ?>/images/<?php if($_COOKIE["p".$page['page_id']] =="1"){echo"minus";}else{echo"plus";}?>_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" border="0" alt="+" />
That's it. Your expand/collapse state will now be saved in temporary session cookies, and restored on each page refresh.
You could add an expiration date to the Javascript function "writeSessionCookie()" so that it will remember the state between sessions.
(Update: Attached complete file with changes incorporated. Compatible with 2.6.1 and 2.6.2. Maybe also earlier versions, but not tested.)