Questions tagged [json]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
35
votes
5answers
10k views

How can I retrieve channel data in json format?

I've played around with a few implementations but I still don't feel like either is right. I first came across building the JSON itself. This would be in a file at "craft/templates/entries.json". [ ...
8
votes
1answer
456 views

Console script tags garbling up non-html output (e.g. json) when in devMode

I have a plugin returning json from a controller action using $this->returnJson(...). Works great in production, but when devMode = true, the json is invalidated because Craft is still dumping the ...
7
votes
2answers
930 views

Can I change which 'Format' options are available in my Rich Text field?

I want to update my Rich Text field so only H1, H2 and H3 are the available options in the 'Format' selector. Is this possible?
6
votes
2answers
2k views

Craft CMS and JS/MVVM frameworks

Does anyone have an experience in using Craft in conjunction with a front-end JS MVC/MVVM framework such as Backbone, Ember or Angular? We have a project coming up where there may be a lot of JS ...
5
votes
2answers
2k views

HTML/View Source button not working/showing in WYSIWYG Craft 2.5 / Redactor II 1.1.0

The "HTML" button no longer seems to show in the WYSIWYG. The button is set in the Redactor config file like so: { "buttons": ["html","formatting","bold","italic","unorderedlist","orderedlist","...
5
votes
2answers
2k views

HTML Purifier Config File

I noticed the following new feature in Craft CMS 2.6.2973: Added the “HTML Purifier Config” setting to Rich Text fields. I can't see any mention or any example of config files in the Craft CMS docs ...
5
votes
2answers
2k views

Creating entries from JSON feed - plugin?

I'm wondering if this plugin already exists and I'm just not finding it on Github or via Google. Essentially looking for a CraftCMS version of the ExpressionEngine plugin called "Data Grab" - http://...
5
votes
1answer
2k views

What criteria can the Element API plugin accept?

I have a structure called "locations" that contains two entry types: State Location I'd like to access specific states at the URL locations/ny.json, for example, and get a JSON object with all the ...
5
votes
2answers
809 views

Access Element API JSON in another environment

First Craft project and off to a great start. I don't think i'll ever touch Wordpress again. :) I'm using the Element API plugin to build out one of my feeds of entries and hoping to use that on a ...
5
votes
1answer
933 views

Use of undefined constant JSON_HEX_TAG

I'm running PHP 5.3.3, which the docs say is supported, but if I try to go to the main admin page or go to add a field, I'm getting an error: Use of undefined constant JSON_HEX_TAG - assumed '...
4
votes
2answers
2k views

Passing multiple parameters to the Element API

How should I go about passing multiple parameters to the Element API? The scenario is that I would like to display all my categories for a given section in a form, and allow the user to select ...
4
votes
3answers
914 views

Creating environment variable from JSON file

Brand new to Craft here. I'm trying to port across my gulp workflow to Craft and basically everything has gone super smooth. Just one last obstacle due to my lack of knowledge of the Twig templating ...
3
votes
3answers
321 views

BaseController::returnJson & devMode interference

While developing an API for a client site I recognized that there was a tag being returned after our JSON response (generated using BaseController's returnJson method). I copy & pasted some of ...
3
votes
2answers
4k views

Passing JSON to Twig

I'm creating a multilingual site and I'm looking to pass some additional configuration data to Twig so I can use it in my template. For example, suppose I have a configuration like this: { "...
3
votes
2answers
2k views

Removing P tag's in rich text area's

Before you think this has already been answered, yes it is but I can't manage to get that fix working so I'm looking for another one. I have a "title" field in a couple of my matrix blocks but my ...
3
votes
1answer
1k views

Get Assets in JSON with ElementAPI

I'm trying to integrate the ElementAPI plugin into my site. Essentially, I need to output all of the assets within the website into a JSON file that I can link to in the load manifest of PreloadJS. If ...
3
votes
2answers
1k views

Craft as a CMS for mobile app content

We're just looking at potentially using Craft as a CMS to serve up content to a mobile apple/android app. Ideally content would be delivered as JSON and there be some sort of authentication from the ...
3
votes
2answers
2k views

PHPUnit - Warning: “Header already sent”

I'm trying to cover the plugin controller with unit tests, but when I try to run phpunit this error shows up: Warning: Cannot modify header information - headers already sent by (output started at /...
3
votes
1answer
218 views

Element API: Entry field inside a Channel entry being passed into JSON file

Hopefully my titles makes some sense but I will try to elaborate. I have a Channel entry called Movies that I am using the Element API to turn into JSON. There is a field inside that called Movie ...
3
votes
0answers
268 views

Getting related entries along with entry using the Element API plugin

I want to list all the related entries to the entry I am displaying using the Element API plugin. I have a channel called series and another called episodes, the episodes have a relationship with 1 ...
2
votes
2answers
779 views

ElementAPI - Can I use javascript/ajax to load json

Probably a dumb question, but since i wasn't sure while reading on github, i'll ask here. I am wondering if I can reach the JSON I created with an URL or is it only for use in PHP? I would like to ...
2
votes
2answers
327 views

How to skip the first X entries using ElementAPI

I'm looking how to use the .offset(x) parameters of craft.entries inside the ElementAPI. I tried to add 'offset' => 1 before, after and inside the criteria array, but the x first entries are still ...
2
votes
2answers
249 views

How to store custom data into a user

I need some direction in how to store (complex) data into users (best practice) I'm working on a project for a fitness app. I created a structure with 2 levels for workouts where level 1 entries are ...
2
votes
1answer
397 views

Feed Me: How to format JSON for a table field?

I need to import some data into a table field. What's the best way to format the data in my original JSON feed? I've tried this: [ "first value", "second value", ] and this: [ {"col1":...
2
votes
1answer
362 views

Feed Me: Importing a relationship between elements

I want to import a bunch of films, which all have certain genres. The genres have already been set up as Categories in Craft, so each genre already has an Element ID (if that's relevant). Here's a ...
2
votes
1answer
1k views

Image transforms not working properly

I have 2 basic JSON files, the only difference between the files is the product.type('') In my general.php I have turned on 'generateTransformsBeforePageLoad' => true, The first JSON file (200 ...
2
votes
1answer
5k views

Loop through JSON object in Twig from the database

I've written a custom plugin that stores data as JSON in a TEXT column (field_gridcontrol) in Craft's content table that looks something like this: [ { "id": "35", // id is an element's id "...
2
votes
1answer
2k views

How do I add meta data and a page title through ajax?

I have looked a lot through this StackExchange but I guess I am not too advanced in using AJAX/Json. My aim is to have page transitions using Ajax. This was rather easy to accomplish following this ...
2
votes
1answer
193 views

Using setExpires on returnJson

From a custom plugin controller, I am returning data as json using $this->returnJson($data). I need to be able to set the Cache-Control headers for my forward cache proxy to handle caching ...
2
votes
1answer
126 views

Looping out a lot of entries.

Ok, so I'm looping through a lot of entries. It's a large request, and I had to up php memory limit to 512M. But I'm sure there is a less memory consuming way to do this. Also, I want to cache the ...
2
votes
1answer
1k views

Return json formatted entries and include a header for Access-Control-Allow-Origin

Hi Not sure on the best way to do this. I have some javascript that requires a json formatted file to populate a calendar. I can do this in php by adding the following to the file that is being ...
2
votes
1answer
1k views

JQuery $.ajax “:success” form logic with Plugin Controller?

I'm working on a simple plugin to facilitate front-end, anonymous lead generation forms submitted to Salesforce via cURL to it's Web-to-Lead servlet. The logic and data transfer are working (debug ...
2
votes
1answer
785 views

Element API + JSON data in template

Is there any way to include the JSON response from element API in a template. Let's take the following example: /case-studies.json returns: { data: [ { title: "American ...
2
votes
1answer
975 views

Element API User example

I am attempting to build an application where Craft handles all of the API based data (JSON). I am using the Element API. I can't find an example anywhere online that outputs Users. I am trying to ...
2
votes
1answer
214 views

Getting all the values out of a field as array of values

I have a multi-select field in my work section I want to get the values either with the Element api as json or an array of simple values in my template.
2
votes
1answer
601 views

Output Matrix Block with Element API Plugin

Below is my code to output the news entires under the "news" section of my site using the Element API. My question is how do I output the matrix block with a block type of "text" with a field called "...
2
votes
0answers
178 views

JsonLD & Schema

What is the best way to use Json-LD schema in the templates for Craft 3? I would like to dynamically load parts of the info. I know about the SEOmatic plugin but looking for a way to do it on my own.
2
votes
0answers
691 views

Ordering Element API by Category and Title

I'm looking for a way to order the ElementAPI json array by category and title. I can only get one to work whether it's 'group' => 'stockistRegion.first().title' or 'order' => 'title' using the ...
2
votes
1answer
366 views

Creating a guest entry, with a Matrix field, using Ajax

I'm trying to submit a guest entry by building a javascript array of objects to mimic a form submission and submit using ajax. I've managed to successfully submit the entry with just a title but when ...
1
vote
3answers
2k views

How to store json data in a custom fieldtype so that it's data can be referenced as attribute values?

I would like to store a json object in a custom fieldtype, and be able to traverse the object's attributes using twig dot syntax in my template. I am currently storing the raw json object as a string, ...
1
vote
2answers
266 views

Querying channel entries hits memory limit

We have a channel that has about 700 entries but is paginated with a limit of 30 entries. Our client is looking to add a button so users can print out all entries. One of our proposed solutions was to ...
1
vote
1answer
1k views

Best solution for get json results from third party api?

I need to get blog posts from hubspot api using this approach. http://developers.hubspot.com/docs/methods/blogv2/get_blog_posts Since craft uses twig I'm unable to use php in the templates, so I ...
1
vote
1answer
642 views

Craft 3 Plugin Controller - returnJson() replacement?

In Craft2, when making an ajax request to a plugin controller action, you would use the returnJson() method which is part of the BaseController class - which your plugin controllers extend. This sets ...
1
vote
2answers
401 views

Feed Me: Valid JSON file returning as invalid

Can anyone see why this data would return as invalid in Feed Me? It's valid JSON. [ { "FIELD1":"1", "FIELD2":"Airmax", "FIELD3":"150-08ACW-134 ", "FIELD4":"...
1
vote
3answers
82 views

Placid plugin - limit returned results

I'm trying to limit the results to 5, but its returning all of the results instead. I am using the below code: {% set options = { cache : false, query : { limit : 5 } } %} {% set timeline =...
1
vote
1answer
689 views

Element API: Remove additional set of square brackets from JSON-String

We're currently having an Android-App access some of the entries of our Craft-based website. We are currently still using a self built API, and for easier creation of new API-Calls we are trying to ...
1
vote
1answer
548 views

Redactor can't add image into toolbar

In my rich text field I want to add images to the toolbar. I have done everything that has to be done: I've added "image" to the Standar.json file and selected the Standard.json to be used for the ...
1
vote
1answer
367 views

When saving an Entry, I receive a JSON response rather than returning to the Entry's edit page

Craft Version: 3.0.4 Web Server: Apache + Nginx proxy Recently I've been working on a couple of Craft 3 projects for deployment on my institution's web servers. In the past, I've successfully ...
1
vote
1answer
392 views

Using Craft Prune - convert JSON Array of Objects to simple array

I am using the Craft Prune plugin (https://github.com/mattstauffer/craftcms-prune) to pull out a JSON array of entries from a section of my site with the aim of integrating the data into a typeahead ...
1
vote
1answer
183 views

Dealing with long lists of items

I'm looking for the best way to deal with long lists of items. In this case a subsite is a council library area which must publish a list of new books each month. In a perfect world I would suck this ...