Page 1 of 1

Better view in listcontent.php

Posted: Mon Sep 12, 2005 5:11 pm
by redkevin11
I needed a better view for listcontent.php in the admin, so here's my quick-n-dirty hack:




In listcontent.php:

CUT

Code: Select all

  				if ($modifyall)
  				{
  					#Figure out some variables real quick
  					$depth = count(split('\.', $one->Hierarchy()));
  
  					$item_order = substr($one->Hierarchy(), strrpos($one->Hierarchy(), '.'));
  					if ($item_order == '')
  					{
  						$item_order = $one->Hierarchy();
  					}
  
  					#Remove any rogue dots
  					$item_order = trim($item_order, ".");
  
  					$num_same_level = 0;
  
  					#TODO: Handle depth correctly yet
  					foreach ($content_array as $another)
  					{
  						#Are they the same level?
  						if (count(split('\.', $another->Hierarchy())) == $depth)
  						{
  							#Make sure it's not top level
  							if (count(split('\.', $another->Hierarchy())) > 1)
  							{
  								#So only pages with the same parents count
  								if (substr($another->Hierarchy(), 0, strrpos($another->Hierarchy(), '.')) == substr($one->Hierarchy(), 0, strrpos($another->Hierarchy(), '.')))
  								{
  									$num_same_level++;
  								}
  							}
  							else
  							{
  								#It's top level, just increase the count
  								$num_same_level++;	
  							}
  						}
  					}
PASTE it UNDER

Code: Select all

		foreach ($content_array as $one)
		{
FIND the line with:

Code: Select all

echo "<td><a href=\"editcontent.php?content_id=".$one->Id()."\">".$one->Name()."</a></td>\n";
REPLACE the whole thing, including echo with:

Code: Select all

//Begin Custom Code
                echo "<td>";                
                for($i = 1; $i < $depth; $i++) {
                    echo "-    ";
                }
                echo "<a href=\"editcontent.php?content_id=".$one->Id()."\">".$one->Name()."</a></td>\n";
//End Custom Code
Looks like this:
Image

You can also download the attached listcontent.txt and just replace it with yours... change the extention to php!

I worked for a long time trying to make a collapsable menu like {startCollapseMenu} plugin (starts showing only top-level pages, then click and it expands... same for all levels of hierarchy ), but it seems that you can't collapse between tags, and I would have to rewrite the structure of the page completely.  Also I can't seem to find a function to see if a page has a child or not, so I was making every single page expandable... even ones with nothing under it.


Hopefully there will be an expandable menu in a future version. 

[attachment deleted by admin]

Re: Better view in listcontent.php

Posted: Mon Sep 12, 2005 8:53 pm
by arl
This is great! It makes it much easier to see the structure of the pages.

Allan

Re: Better view in listcontent.php

Posted: Mon Sep 12, 2005 8:58 pm
by Ted
Yeah, this is a nice patch.  It's on the TODO list (unless someone wants to make a patch files against svn to make it a quicker process).

Re: Better view in listcontent.php

Posted: Mon Sep 12, 2005 10:00 pm
by sjg
I added this as an option. Users can turn indenting on or off using their Admin Preferences.

It's committed in svn.

Re: Better view in listcontent.php

Posted: Mon Sep 12, 2005 10:38 pm
by Ted
And it's off of my TODO list.  :)  Thanks.

Re: Better view in listcontent.php

Posted: Tue Sep 13, 2005 2:03 pm
by redkevin11
Wow!
Great to see the code put to use!

Have you considered making the list expandable/collapsable?  A site I'm working on has over 50 pages now, but only 4 top level items.  I changed the page item limit to fit them all on one page, but it would be great to just see the top level items, and expand as needed... or have an "expand/contract all" check box.

I worked on it for a  while, but couldn't get the 's to collapse.

Re: Better view in listcontent.php

Posted: Thu Sep 15, 2005 12:39 am
by sjg
Expand and collapse have been added in svn. I haven't implemented expand all or collapse all buttons. I wanted to make sure this worked before finishing that part up.

Thanks,
___Samuel___

Re: Better view in listcontent.php

Posted: Thu Sep 15, 2005 6:48 am
by jah
This will be great. I found a couple of bugs when updating from svn.

Undefined property: hierarchy in ...index.php on line 98
Undefined index: collapsed in .....lib\classes\class.content.inc.php on line 54

'contract' missing in lang file

Jon

Re: Better view in listcontent.php

Posted: Thu Sep 15, 2005 5:16 pm
by sjg
Thanks for the info.

I noticed the "Undefined property: hierarchy" last night; I'll see where that's coming from.

Did you update your schema to version 11? I'm not sure about that second error message, since nothing mentions "collapsed" anywhere near line 54 in class.content.inc.php.

I'll add "expand" and "contract" to the language file. Stupid oversight on my part...

Thanks,
___Samuel___

Re: Better view in listcontent.php

Posted: Thu Sep 15, 2005 6:21 pm
by jah
You're right. I missed the new schema. It looks perfect now. :-)

Re: Better view in listcontent.php

Posted: Thu Sep 15, 2005 11:00 pm
by sjg
OK. I've added the expand all and collapse all to the svn version. If someone wants to step up with decent icons for those links, I'll happily replace the ones I made.

Let me know if you run into any problems.

___Samuel___