List pages by template in Panel?

When editing a page, in the left side of the panel, I’d like to break out the “pages” section by template type. So if some of the children use the default page template, and others use a “blogpost” template, for example, there would be two different sections: one titled “Pages” and one titled “Blog Posts”.

I assume this requires tweaking the panel code somewhat. If anyone has some snippets to point me in the right direction, that would be wonderful!

Yea, you would need to edit the panel core. Just the basic concept:

  1. In app/controllers/views/pages.php split up the subpages collection into the different ones that you want
  2. Same file: create a Snippet(‘pages/sidebar/subpages’) for each of them
  3. Same file: Pass them through to Snippet(‘pages/sidebar’)
  4. In panel/app/snippets/pages/sidebar.php: add/replace <?php echo $subpages ?> with your multiple output subpages snippets

That said, it is kinda hacky. You would potentially need to take care of quite a few edge cases (no subpages existing…). Also the subpages overview page would still be the old one.

Thanks for pointing me in the right direction! I’ll have to see how messy this is going to be.

Oh, or (I just realized this) - if you really don’t care about any separation of controller, view and so on:

Edit panel/app/snippets/pages/sidebar/subpages.php, duplicate the lower part (after the whole h2-block) and adapt it. Besides a few other lines, mainly

// old
<?php foreach($subpages as $subpage): ?>

// new
<?php foreach($subpages->filterBy('intendedTemplate', 'bla') as $subpage): ?>

As I said, a few more lines would need editing and some kind of heading for the different subpages sections.

Not recommending it at all, but it is a theoretical possibility – at least briefly thinking about it, I guess it would be one (not sure tho).

Also, there is the pagination thing to take care of, you’d have to find a solution how to handle that.