getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

Additional extension for "pageViews" #571

Open ryami333 opened 4 years ago

ryami333 commented 4 years ago

I want to be able to extend the "views" property of the Page model (using custom plugins), so that I can use them with the rest API. I would be able to make an API request like this:

GET https://mysite.com/api/page/home?view=my-custom-view

By configuring a custom Page model "view" like this:

// plugin/my-custom-view/index.php

<?php

Kirby::plugin('my-custom-view-plugin', [
    'pageViews' => [
        'my-custom-view' => [
            'id',
            'title',
            // …etc
        ]
    ],
]);
ryami333 commented 4 years ago

As a somewhat-related aside, I couldn't find any mention of the "view" parameter described in the API documentation. It wasn't until I went digging around in the source and seeing the parameter attached to queries made from the CMS's Vue app that I noticed it exists. I really think this could be a useful piece of documentation for future users.