Panel customization: Adding a field to the subpage list

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?

I now have a solution based on @flokosiol’s plugin for the sidebar.
However, I still had to edit the core to get the project number to display on the sorting page.

Would be great if a more flexible implementation could be considered for future releases. I’m sadly far from talented enough to propose a fitting solution.

You can modify the panel / sidebar with a hidden field…

  1. Gallery Grid
  2. Jump List

It’s kind-a-hackish, but it works… :stuck_out_tongue:

- edit - The way I did it, was embedding a field that was not visible / doing nothing at all.

But it allowed me to inject some javascript - which added extra functions to the panel (can’t live without it - these days!)

1 Like

I did forget about your hacks (although I use gallery grid in my blog) :smile:

1 Like