Showing only subpages

Hey there!

Since I’m often using pages solely as containers for children like news, portfolio items, staff or gallery images, I tried to simplify the panel for such behaviour.

TL;DR:
If the “show only subpages” option is true only the sidebar will be visible, in full width. And instead of “pages” it will print the name of the subpage container. In my case that’s “news”.

It’s quite hacky and not really clean, but it works. For sure there are downsides to this, such as not being able to edit the title anymore, but most of the time this isn’t even necessary.

Here are the files I modified:

Adding a class to the “bars” element in /panel/app/views/pages/show.php, line 3

<div class="bars bars-with-sidebar-left cf seiten<?php echo $page->nurseiten() ?>">

Overwriting the CSS for the side- and mainbar in /panel/assets/css/panel.css

.seitentrue .sidebar {
	width: 100%;
}
.seitentrue .mainbar {
	display: none;
}
.seitentrue:before {
	width: 100%;
}

Setting the title of the “pages”-sidebar to the page title in /panel/app/controllers/views/pages.php, line 66

// Nur Unterseiten?
if($page->nurseiten() == "true") {
      $titel = $page->title();
}
else {
      $titel = l('pages.show.subpages.title');
}
		
// create the snippet and fill it with all data
$subpages = new Snippet('pages/sidebar/subpages', array(
      'title'      => $titel,
      'page'       => $page,
      'subpages'   => $children,
      'addbutton'  => !api::maxPages($page, $blueprint->pages()->max()),
      'pagination' => $children->pagination(),
));

Is there another way to do panel extensions like this?
Everytime Kirby gets an update to the panel these changes need to be made again…

Maybe an optional folder with JavaScript- and CSS-files which extend the panel would be a good idea?

I also believe, something like this should exist in the panel.
Using an article as a category is a common way to organize your content and still isn’t nicely supported with standard blueprints.

If you use the subpages/items as “blocks” in the site, you could keep the parent page’s details visible, and use the title and text for these blocks. That way any editor could change the title of the blocks easily, perhaps use the text field to customize the “read more” link.

Today I wrote a field plugin for that. Basically to level up my Kirby skills, because I never did anything like this before. But maybe it’s that what @thguenther is looking for :smile: – if not I’ve at least learned a lot …

It’s a new field type (called „subpagelist“) which can be used in any blueprint.

Here’s a quick preview of how it looks like.

EDIT: You can find it on Github, but there are still some issues which need to be fixed …

Wow, this looks awesome @flokosiol! Gonna test this on my next project.

1 Like

Thanks for your reply @thguenther.

I would like to create a new topic for my plugin within this forum category. I think that a lot of people won’t notice, because it’s just mentioned in a post replying to an existing topic. But I absolutely don’t want to spam this forum. Any opinions, maybe from the advanced forum users @bastianallgeier @texnixe @distantnative?

Thanks. Flo.

You could create a new post in the plugins category to get more attention and you might want to get in touch with @DieserJonas to have your plugin featured on http://getkirby-plugins.com.

2 Likes

Thanks for your reply @texnixe. Really quick and helpful as always :wink: