LoginSignup
0
0

More than 5 years have passed since last update.

Craft 2 のテンプレートでユーザー一覧を JSON で返す

Posted at

ユーザーの情報をテンプレートで表示することはほとんどないが、Feed Me を使ったデータ移行の際に利用できる。

{% set response = [] %}
{% for user in craft.users.limit(null) %}
  {% set response = response | merge([{
    firstName: user.firstName,
    lastName: user.lastName,
    userName: user.username,
    email: user.email,
    id: user.id
  }]) %}
{% endfor %}

{% header 'Content-Type: application/json; charset=utf-8' %}
{{ response | json_encode() | raw }}

下記も参考に。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0