Panel customization: Adding a field to the subpage list

Hello everyone,
I was wondering if there is a way to show more than just the page title in the subpages list. Our client would like to see his custom project number next to the project title. Any idea if this is possible?

I am talking about the following list:

It could simply be seperated with a comma like:
087, Engineering the World
064, Fridericianum Foyer


There is no option to achieve that. You could modify the core code, though.


1 Like

Hello @rbnschlz,
At the moment, there is no way to do this that I know of other than to “hack” the panel.
This means having to look at the panel code that creates the pages list and adding a column with your custom project number.

Now that I think of it…
You could try this workaround (not very nice):

  • Create two title fields. title is the default and is used in the panel. page_title (or anything else you want to call it) is the actual title you’ll use in your frontend.
  • In title, enter the page_title and the custom project number separated by a comma.
  • Potentially create a custom field that does that automagically for you :wink:

I’m not proud of the potential workaround but if it suits you and your clients, it was worth sharing :wink:

1 Like

not ideal, but I’ll take it for now.
Would be great if the subpages list could be more customisable in the future!

I thought about something like this as well, but it seems rather complicated for such a small change.

1 Like

is it Possible to create a Plugin For That?

Plugins cannot extend the panel sidebar for now.

Hmm yeas. That Sounds Logical

@coreytegeler asked me something comparable for my subpagelist plugin a while ago. Although I didn’t want to implement a custom template (because I’m using the sidebar snippet as it is) I described how to modify my plugin to use a custom template as mentioned in this comment.

Maybe this is an option. It’s hacking a plugin instead of hacking core :stuck_out_tongue_winking_eye:


Thanks, got it working for now.
I didn’t completely understand your proposed template.php file and deleted some of the if else statements since they were throwing an error. Code looks like this now:

<h2 class="hgroup hgroup-single-line hgroup-compressed cf">
	<span class="hgroup-title">
		<a href="<?php __($page->url('subpages')) ?>"><?php __($title) ?></a>
	<span class="hgroup-options shiv shiv-dark shiv-left">
		<span class="hgroup-option-right">
			<a title="<?php _l('') ?>" href="<?php __($page->url('subpages')) ?>">
				<?php i('pencil', 'left') ?><span><?php _l('') ?></span>
			<?php if($addbutton): ?>
				<a title="+" data-shortcut="+"<?php e($addbutton->modal(), ' data-modal') ?> href="<?php __($addbutton->url()) ?>">
					<?php i('plus-circle', 'left') ?><span><?php _l('') ?></span>
			<?php endif ?>

<?php if($subpages->count()): ?>
	<ul class="nav nav-list sidebar-list datalist-items">
		<?php foreach($subpages as $subpage): ?>
				<a class="draggable<?php e($subpage->isInvisible(), ' invisible'); ?>" data-helper="<?php __($subpage->title(), 'attr') ?>" data-text="<?php __($subpage->dragText()) ?>" href="<?php __($subpage->url('edit')) ?>">
					<?php echo $subpage->icon() ?><span><?php __($subpage->title()) ?></span>
					<small class="marginalia shiv shiv-left shiv-white"><?php __($subpage->projnum()) ?></small>
				<a class="option" data-context="<?php __($subpage->url('context')) ?>" href="#options"><?php i('ellipsis-h') ?></a>
		<?php endforeach ?>

	<?php echo $pagination ?>

<?php else: ?>
		<p class="marginalia">

		<?php if($addbutton): ?>
			<a class="marginalia" title="+"<?php e($addbutton->modal(), ' data-modal') ?> href="<?php __($addbutton->url()) ?>">
				<?php _l('') ?>
		<?php else: ?>
			<?php _l('') ?>
		<?php endif ?>

<?php endif ?>

Could you possibly tell me if this could break at any point?

Since the template.php in the gist is a mixture of two core templates I’m unfortunately not really able to explain it :confused:

But if it’s working for you, I think it’s fine :wink:

I was just wondering what the following lines in your original template.php file were for?

<?php if ($field->subpages()->count() > 0): ?>

<?php else: ?>
  <div class="input input-with-items">
    <div class="item subpagelist-item-empty">
      <?php echo l::get('subpagelist.empty') ?>
<?php endif ?>

I excluded them for now due to an error caused by line 1.

The if-clause should check, if subpages exist and otherwise display a message. I had a short look at the plugin code and $field is not passed to the template.

This could work instead for line 1 (untested) …

<?php if ($subpages->count(): ?>
1 Like

You can alternatively edit the content of the title field of all pages to add the project number there.
If you need you can drop that number within your PHP code!

Or you can use a separate field with the project number to sort your pages. In this case you see the number in the right column of your hardcopy.

I’d like to avoid having the number in the actual title field. Not exactly the best solution in my opinion.
How would I go about sorting the pages by a specific field? Thought about this as well but couldn’t find a proper solution.

There is no option to sort pages by a specific field, you can sort alphabetically (by title), by date, and by number.

1 Like

Thought so, thanks. Maybe something to consider for future releases?

Yes, that’s worth considering.

Edit: I created an issue on GitHub.

I thought the project number may be a …

but have not checked this. Sorry!

What do you suggest should I write in my blueprint?