laraluke/statamic-api-select 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

laraluke/statamic-api-select

Composer 安装命令:

composer require laraluke/statamic-api-select

包简介

README 文档

README

Utilise API endpoints for your Select Fieldtype options.

License

API Select requires a license.

You can purchase one at https://statamic.com/marketplace/addons/api-select

You may use API Select without a license while Statamic is in Trial mode.

Installation

Require it using Composer.

composer require laraluke/statamic-api-select

Publish the assets:

php artisan vendor:publish --provider="Laraluke\ApiSelectFieldtype\ServiceProvider"

Using the API Select Fieldtype

Add the fieldtype to your fieldset/blueprint. You will then need to configure the following settings:

Endpoint Type

This is to define whether or not your endpoint value is a URL or a config variable.

Endpoint

If your endpoint type is a URL your endpoint value will look like this:

https://jsonplaceholder.typicode.com/users

If your endpoint type is a config variable your endpoint value will look like this:

endpoints.users

and your endpoints.php file would look something like this:

return [
    'users' => 'https://jsonplaceholder.typicode.com/users',
];

Cache Duration

This is how long API requests will be cached for in minutes.

Set this value to 0 if you don't want to cache results.

Data Set Key

If your data set isn't in the top-level of your API response you can define it's location using dot syntax.

So if your API result looks like:

{
    "data": {
        "users": []
    }
}

You would set the data set key value to:

data.users

Item Key

Define the unique identifier to be used as the option value.

So if the iteration in your API result looks like this:

{
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
}

You might set your item key to:

id

Item Label

Define the value to be used as the option label.

So if the iteration in your API result looks like this:

{
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
}

You might set your item label to:

name

Using the API Select value in your templates

Let's assume your API select field handle is api_select_users API response is like so:

[
    {
        "id": 1,
        "name": "Leanne Graham",
        "username": "Bret",
        "email": "Sincere@april.biz",
    },
    {
        "id": 2,
        "name": "Ervin Howell",
        "username": "Antonette",
        "email": "Shanna@melissa.tv",
    }
]

Single-choice API Select

{{ api_select_users.name }}

// Returns
Leanne Graham

Multi-choice API Select

{{ api_select_multi }}
    {{ name }}
{{ /api_select_multi }}

// Returns
Leanne Graham
Ervin Howell

统计信息

  • 总下载量: 452
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固