Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
Cleaning my mess
Browse files Browse the repository at this point in the history
  • Loading branch information
Zignature committed Nov 29, 2021
1 parent 9f87067 commit 60470f2
Show file tree
Hide file tree
Showing 7 changed files with 2,233 additions and 41 deletions.
79 changes: 38 additions & 41 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,23 @@ Since legacy custom fields do not have their own table they will work fine eithe

### `xhr="yes"`

Set `xhr` to yes to only output data when an XMLHttpRequest is detected. Do not set this to yes if you are using JSONP, as JSONP requests are not true XHMLHttpRequests.
Set xhr to yes to only output data when an XMLHttpRequest is detected. Do not set this to yes if you are using JSONP, as JSONP requests are not true XHMLHttpRequests.

### `terminate="yes"`

Set `terminate=` to yes to terminate the template and output your json immediately, with Content-Type headers.

### `json_pretty_print="yes"`

For a better readable output. Combine with `terminate="yes"`. It's handy in the development stage.
Set terminate to yes to terminate the template and output your json immediately, with Content-Type headers.

### `fields="title|url_title"`

Specify which fields you wish to have in the array. Separate multiple fields by a pipe character. If you do not specify fields, you will get all of the default fields' data. The primary key (`entry_id` for entries, `member_id` for members) will always be present and cannot be suppressed by this parameter.

### `content_type="text/javascript"`

Set a custom Content-Type header. The default is "application/json", or "application/javascript" if using JSONP. Headers are only sent when `terminate` is set to "yes".
Set a custom Content-Type header. The default is "application/json", or "application/javascript" if using JSONP. Headers are only sent when terminate is set to "yes".

### `jsonp="yes"`

Set `jsonp` to yes to enable a JSONP response. You must also specify a valid callback. You are encouraged to set `terminate` to yes when using JSONP.
Set jsonp to yes to enable a JSONP response. You must also specify a valid callback. You are encouraged to set terminate to yes when using JSONP.

### `callback="yourCallbackFunction"`

Expand Down Expand Up @@ -139,15 +135,15 @@ for (i in data) {
}
```

If you require a different output format for the date fields, set the `date_format=` parameter. This uses the php date() function. common formats include "U" (unix timestamp in seconds), "c" (ISO 8601) or "Y-m-d H:i" (2011-12-24 19:06).
If you require a different output format for the date fields, set the date_format= parameter. This uses the php date() function. common formats include "U" (unix timestamp in seconds), "c" (ISO 8601) or "Y-m-d H:i" (2011-12-24 19:06).

## json:entries

```
{exp:json:entries channel="news"}
```

`json:entries` is a single tag, not a tag pair. Use channel:entries parameters to filter your entries.
json:entries is a single tag, not a tag pair. Use channel:entries parameters to filter your entries.

#### json:entries Default Fields

Expand Down Expand Up @@ -175,7 +171,7 @@ This will add categories to the entries response

##### `show_category_group="1|2"`

When paired with `show_categories="yes"`, this will display only categories from the specified groups.
When paired with show_categories="yes", this will display only categories from the specified groups.

#### json:entries Custom Fields

Expand All @@ -189,22 +185,24 @@ The data will be the Unix timestamp, accurate to milliseconds. This is because t
your_date_field: 1385661660000
```

##### Grid
##### File Grid

The data will include an array of Grid rows, including the row_id and the column names:
The data will include an array of File Grid rows, including the row_id, the url to the file and the column names:

```
your_grid_field: [
{
row_id: 1,
my_col_name: "foo",
other_col_name: "bar"
},
{
row_id: 2,
my_col_name: "baz",
other_col_name: "qux"
}
"your_grid_field": [
{
"row_id": 1,
"file": "the-url-to-your-file",
"my_col_name": "foo",
"other_col_name": "bar"
},
{
"row_id": 2,
"file": "the-url-to-your-file",
"my_col_name": "baz",
"other_col_name": "qux"
}
]
```

Expand All @@ -216,7 +214,7 @@ When a custom field is duplicated, the data will be returned in an array. In the
```
"your_fluid_field": {
"your_custom_field": "Your Fluid Custom Field Contents",
"your_duplicated_custom_field": [
"legacy_duplicated_custom_field": [
"Your Duplicated Fluid Custom Field Contents 1 (first instance)",
"Your Duplicated Fluid Custom Field Contents 2 (second instance)"
],
Expand Down Expand Up @@ -250,24 +248,22 @@ When a custom field is duplicated, the data will be returned in an array. In the
}
```

##### File Grid (EE v5.1+)
##### Grid

The data will include an array of File Grid rows including the row_id, the file and the optional extra column names:
The data will include an array of Grid rows, including the row_id and the column names:

```
your_file_grid_field: [
{
row_id: 1,
file: "URL-to-your-file",
my_col_name: "foo",
other_col_name: "bar"
},
{
row_id: 2,
file: "URL-to-your-file",
my_col_name: "baz",
other_col_name: "qux"
}
"your_grid_field": [
{
"row_id": 1,
"my_col_name": "foo",
"other_col_name": "bar"
},
{
"row_id": 2,
"my_col_name": "baz",
"other_col_name": "qux"
}
]
```

Expand Down Expand Up @@ -597,10 +593,11 @@ function yourCallbackFunction(data) {

### v1.1.9

- ExpressionEngine 3.x compatibility
- EE3 compatibility
- Added relationships support for grids as per [ahebrank's](https://github.com/ahebrank) [commit](https://github.com/rsanchez/json/pull/65)
- Added `/system/user/addons/json/addon.setup.php` for EE3
- Added `/system/user/addons/json/README.md` for the add-on manual in the control panel (as of EE3)
- **Note:** not tested with Assets, Matrix, Playa and Channel Files fieldtypes/modules

## Attribution

Expand Down
Loading

0 comments on commit 60470f2

Please sign in to comment.