Welcome, Guest. Please login or register.
Did you miss your activation email?
May 16, 2012, 09:52:04 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155094 Posts in 21661 Topics by 7721 Members
Latest Member: arrow345
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: patch to remember visibility while sorting v2.5.2  (Read 3787 times)
faultymonk

Offline Offline

Posts: 6


« on: November 09, 2005, 09:01:35 AM »

Klugy, but works.

Should work with the MySQL version as well.

[attachment deleted because of being too old]
Logged
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7970



WWW
« Reply #1 on: November 09, 2005, 11:01:16 AM »

What does this patch do? A little bit more explanation would be good.

Thanks

Matthias
Logged
faultymonk

Offline Offline

Posts: 6


« Reply #2 on: November 09, 2005, 11:10:25 AM »

Basically, I got tired of having to re-expand the pages list when reordering using multiple levels.  Everytime I asked a page to be moved up or down, the nested pages would collapse.  This patch keeps the expanded list open after a move-up or move-down, so that if you need to move it multiple times, you won't have to re-expand the list manually.

Shane
Logged
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7970



WWW
« Reply #3 on: November 09, 2005, 12:09:04 PM »

Thanks

if i understand correct, we have in admin-interface the following structure

     page1
     -page2
          subpage1
          subpage2
     page3
     ....

normaly all pages are collapsed looks like

     page1
    +page2
     page3

When you normally move a page the expanded pages collapse and you have to expand this again.

With your patch the expanded pages now should stay expanded.

Would be nice if it is so. I tested your patch and had the same result as before, all pages collaps  huh

Added my changed files, please a have a look at this

Thanks
Matthias

[attachment deleted because of being too old]
Logged
faultymonk

Offline Offline

Posts: 6


« Reply #4 on: November 09, 2005, 01:48:51 PM »

Hi Matthias,

When you normally move a page the expanded pages collapse and you have to expand this again.
With your patch the expanded pages now should stay expanded.
Would be nice if it is so. I tested your patch and had the same result as before, all pages collaps  huh
Added my changed files, please a have a look at this

Hmm, your files look okay.  Once you've reordered a page, can you look at the source code of your browser and see if you see something similar to:

Code:
<body onload="initEditor();toggle_visibility('p13');toggle_plus_minus('13');toggle_visibility('p11');toggle_plus_minus('11');">

and paste what you see in your <body> tag?

Thanks,
Shane
Logged
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7970



WWW
« Reply #5 on: November 09, 2005, 01:55:59 PM »

thats what's in the source when i've reorderd the pages

Code:
<body onload="initEditor();toggle_visibility('p0');toggle_plus_minus('0');">

Matthias
Logged
faultymonk

Offline Offline

Posts: 6


« Reply #6 on: November 09, 2005, 02:00:34 PM »

thats what's in the source when i've reorderd the pages
Code:
<body onload="initEditor();toggle_visibility('p0');toggle_plus_minus('0');">

Well, according to that, the code is working.  Whatever page you reordered, its parent is '0', meaning that it's top level (so it's not going to expand anything).

So if you have something like:

-ParentPage
  Page2
  +Page1

And you reorder it to:

-ParentPage <-- should stay expanded
  +Page1
  Page2

This should also work if you are multiple levels deep.  But what it doesn't do is to re-expand all of the pages you've expanded.  It only re-expands the tree structure belonging to the node you reordered.

For example, if you started with:

-ParentPage1
 -Page1
   Subpage2
   Subpage1  <-- reorder up
-ParentPage2
  Page1
  Page2

If you reorder Subpage1, it'll look like:

-ParentPage1
 -Page1
   Subpage1
   Subpage2
+ParentPage2

But, if you reorder ParentPage2 from:

-ParentPage1
 -Page1
   Subpage2
   Subpage1 
-ParentPage2  <-- reorder up
  Page1
  Page2

You end up with:

+ParentPage2
+ParentPage1

Shane
« Last Edit: November 09, 2005, 02:16:48 PM by faultymonk » Logged
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7970



WWW
« Reply #7 on: November 09, 2005, 02:32:59 PM »

Curious

step for step
1. see
    ...
    -page2
        subpage1
        subpage2
        subpage3
    ...

2. move up subpage3

3. see
    ...
    +page2
    ...

Whats going wrong?

Matthias
Logged
faultymonk

Offline Offline

Posts: 6


« Reply #8 on: November 09, 2005, 06:50:17 PM »

Hmm.

Okay, when you mouse over an up triangle or a down triangle, does your status bar say something like?

  ...move_down.php?page_id=43&pkluge=33

If it does, could you insert a line in class.admin.php above $pkluge = $_SESSION['pkluge']; that says:

var_dump($_SESSION['pkluge']);

And let me know if when you reorder, that you see a line on the top left like:

string(2) "33"

or a line like

NULL

Shane
Logged
ephraimt

Offline Offline

Posts: 7


« Reply #9 on: March 05, 2006, 10:38:58 AM »

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

Code:
<!-- 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:

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

Code:
<ul id="p<?php echo $parent?>" <?php if($parent != 0) { echo 'class="page_list"'; } ?>>

to

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

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

Code:
<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.)
« Last Edit: March 11, 2006, 10:08:27 PM by ephraimt » Logged
Stefan
Guest
« Reply #10 on: March 10, 2006, 03:59:32 PM »

Can you please supply the fixed file? Saves some time...
Logged
Stefan
Guest
« Reply #11 on: March 12, 2006, 10:22:45 PM »

So you add a cookie for every "+" sign in the list, right?
Seems a bit much...
Logged
ephraimt

Offline Offline

Posts: 7


« Reply #12 on: March 12, 2006, 11:41:43 PM »

 cheesy So don't use it if you don't like it. Thanks for the helpful comment.  rolleyes

They're RAM-based session cookies that go away when the browser is closed!

Logged
arnoutdrenthel

Offline Offline

Posts: 9


« Reply #13 on: July 31, 2006, 03:44:12 PM »

Hmmmmm.... I was looking for this, cuz I really get fed up with all pages collapsing in the admin-interface (especially as I am building a bi-lingual site at this moment).

This solution worked just perfect in Firefox, but in Internet Explorer I only see the first two items

e.g.: My page hierarchy:
- NL
 -- page1
 -- page2
 -- page3
- EN
 -- page1
 -- page2
 -- page3

But in IE I only get to see:
- NL
 -- page 1

Perhaps it has something to do with page 1's visibility is set to "hidden"...?
However, I think I will dive into the coding of /admin/pages/index.php and tweak it so that all pages are visible (not collapsed) as a standard in stead of collapsed. It saves a lot of mouseclicking and frustration when developing a site.
(Perhaps this would be a nice mod for any future updates of WB?)
Logged
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7970



WWW
« Reply #14 on: July 31, 2006, 05:56:57 PM »

Hello,

attached you find my working file for WB 2.6.4. Make a backup of the original, rename the attached file to index.php and copy this file to admin/pages

Hope this helps

Matthias
Logged
arnoutdrenthel

Offline Offline

Posts: 9


« Reply #15 on: August 01, 2006, 08:42:51 AM »

Great! That works...
Thanks!
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!