How to create custom panel home page?

I’m wanting to create a fully customized panel home page. On Discord folks suggested that the way to achieve this is to extend the default site view. While trying to do that, I’ve hit an issue.

When extending other views, only defining the template is sufficient. With the site view, however, only defining the template results in all of the dynamic Vue-defined data and methods and such to be undefined, resulting in errors.

This is what I’ve tried (note that the template markup here is directly copied from kirby/SiteView.vue at main · getkirby/kirby · GitHub).

window.panel.plugin('namespace/customSiteView', {
   components: {
      'k-view': {
         extends: 'k-view',
         template: /*html*/ `
                     :editable="permissions.changeTitle && !isLocked"
                     {{ model.title }}
                     <template #left>
                           <k-languages-dropdown />

                     @submit="$emit('submit', $event)"
               <template #footer>
                  <k-form-buttons :lock="lock" />

When loading that, the site throws the error “isLocked is not defined”.

Not sure if it should be possible to extend k-view and only define the template (i.e. have it inherit all of the other Vue properties defined on k-view), but because this work with other templates it seems that doing the same here should also work.

Grateful for any insight.

Thinking on this a little more: Having to extend/replace the site view in order to simply customize the panel’s home page feels wrong. Feels like it should be possible to create something like home.js that would load a view component that would be responsible for displaying content on the panel’s home page (i.e. everything between the panel-wide header and footer).

Alright, I think I found the least-painful approach for this. Rather than extending the site view, simply create a custom section or field and load that via site.yml.

In /customHomeView/index.js

window.panel.plugin('namespace/customHomeView', {
   sections: {
      customHomeView: {
         template: /*html*/ `

In site.yml

    type: customHomeView

I guess having a custom section or field would be the simplest, like you mentioned above.

Otherwise, instead of overwriting the Site view, having a custom area and then changing a users home option to that could also serve your purpose.

1 Like

Oh, hadn’t realized that it’s possible to create a custom section. That’s a cleaner and more logical approach. Thanks for mentioning it!