Better view in listcontent.php

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
redkevin11
Forum Members
Forum Members
Posts: 29
Joined: Fri May 20, 2005 6:21 pm

Better view in listcontent.php

Post 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]
Last edited by redkevin11 on Mon Sep 12, 2005 5:31 pm, edited 1 time in total.
arl

Re: Better view in listcontent.php

Post by arl »

This is great! It makes it much easier to see the structure of the pages.

Allan
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: Better view in listcontent.php

Post 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).
User avatar
sjg
Power Poster
Power Poster
Posts: 310
Joined: Thu Jan 27, 2005 5:11 pm
Location: Los Angeles, CA

Re: Better view in listcontent.php

Post by sjg »

I added this as an option. Users can turn indenting on or off using their Admin Preferences.

It's committed in svn.
Many modules available from the http://dev.cmsmadesimple.org
The CMS Made Simple Developer Cookbook is now available from Packt Publishers!
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: Better view in listcontent.php

Post by Ted »

And it's off of my TODO list.  :)  Thanks.
redkevin11
Forum Members
Forum Members
Posts: 29
Joined: Fri May 20, 2005 6:21 pm

Re: Better view in listcontent.php

Post 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.
User avatar
sjg
Power Poster
Power Poster
Posts: 310
Joined: Thu Jan 27, 2005 5:11 pm
Location: Los Angeles, CA

Re: Better view in listcontent.php

Post 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___
Many modules available from the http://dev.cmsmadesimple.org
The CMS Made Simple Developer Cookbook is now available from Packt Publishers!
jah
Forum Members
Forum Members
Posts: 147
Joined: Thu Dec 30, 2004 9:09 am
Location: Norway

Re: Better view in listcontent.php

Post 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
User avatar
sjg
Power Poster
Power Poster
Posts: 310
Joined: Thu Jan 27, 2005 5:11 pm
Location: Los Angeles, CA

Re: Better view in listcontent.php

Post 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___
Many modules available from the http://dev.cmsmadesimple.org
The CMS Made Simple Developer Cookbook is now available from Packt Publishers!
jah
Forum Members
Forum Members
Posts: 147
Joined: Thu Dec 30, 2004 9:09 am
Location: Norway

Re: Better view in listcontent.php

Post by jah »

You're right. I missed the new schema. It looks perfect now. :-)
User avatar
sjg
Power Poster
Power Poster
Posts: 310
Joined: Thu Jan 27, 2005 5:11 pm
Location: Los Angeles, CA

Re: Better view in listcontent.php

Post 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___
Many modules available from the http://dev.cmsmadesimple.org
The CMS Made Simple Developer Cookbook is now available from Packt Publishers!
Post Reply

Return to “Tips and Tricks”