wottpal
7/22/2018 - 11:21 AM

site()->drafts() nor working

<?php

Kirby::plugin('wottpal/drafts', [
  'fields' => [
    'drafts' => [
      'computed' => [
        'pages' => function () {
          // RETURNS AN EMPTY ARRAY:
          return site()->drafts()->toArray();

          // CORRECTLY RETURNS ALL DRAFTS:
          $drafts = [];

          foreach(site()->index() as $page) {
            $drafts = array_merge($drafts, $page->drafts()->toArray());
          }

          return $drafts;
        }
      ]
    ],
  ]
]);
panel.plugin("wottpal/drafts", {
  fields: {
    drafts: {
      props: {
        pages: Array
      },
      template: `
        <kirby-field v-bind="$attrs">
        {{pages}}
        <kirby-list>
            <kirby-list-item v-for="page in pages" :key="page.id" :text="page.content.title" v-bind="page.id" />
        </kirby-list>

        </kirby-field>
      `
    }
  }
});