Skip to main content
9 votes
Accepted

HTML Purifier Config File

Something like this in a .json file should work: { "HTML.SafeIframe": true, "URI.SafeIframeRegexp": "%^(https?:)?//(www\\.youtube(?:-nocookie)?\\.com/embed/)%", &...
Brad Bell's user avatar
  • 67.5k
7 votes

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

You need to add "html" in the buttons array, and not "source" in the plugins array.
Andrew Terry Loveday's user avatar
5 votes
Accepted

Get Assets in JSON with ElementAPI

Something like the following should work: // elementapi.php return [ 'endpoints' => [ 'assets.json' => [ 'paginate' => false, 'elementType' => ...
Mats Mikkel Rummelhoff's user avatar
5 votes
Accepted

Removing P tag's in rich text area's

Seems like a simple striptags filter would do nicely in this case: <h1>{{ entry.titleField|striptags('<strong><em><br>')|raw }}</h1> If you're having issues with ...
Mats Mikkel Rummelhoff's user avatar
5 votes
Accepted

Passing JSON to Twig

The answer is to create a custom plugin that will read the json files from the folders in the public directory, parse the json, and pull them into the template. An alternative solution is to use ...
Sam Hernandez's user avatar
3 votes
Accepted

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

You almost certainly don't have to update the meta tags when you use AJAX to load pages like this. Meta tags are not exposed to the end user; they're there for search engine crawlers and social media ...
Mats Mikkel Rummelhoff's user avatar
3 votes
Accepted

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

You can do this a number of ways, and essentially just need an array-like structure to represent the rows. "Table": [ { "one": "Option1", "two": "Option2" }, { "one": "Option3", ...
crawf's user avatar
  • 3,562
3 votes
Accepted

Feed Me: Importing a relationship between elements

Have you set the type of data you're providing for the category field? Each element field allows you to state what attribute the data you're trying to import. Title, ID or slug, which are shown in a ...
crawf's user avatar
  • 3,562
3 votes

HTML Purifier Config File

Following from Brad's answer (I'm not able to comment) I had to escape the backslashes to avoid JSON decode error. Version for Youtube and Vimeo { "HTML.SafeIframe": true, "URI....
sanscheese's user avatar
3 votes
Accepted

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

Though I don't know the Element API, have you tried return $allOverChallenges; instead of return [ $allOverChallenges ]; It looks like you are simply adding these brackets (...
Matthias Redl-Mann's user avatar
3 votes
Accepted

Redactor can't add image into toolbar

You probably don't have an Asset Volume defined yet. The button won't show up if there are no Asset Volumes, regardless of what your Redactor config specifies. To add an Asset Volume, visit the ...
Brad Bell's user avatar
  • 67.5k
3 votes
Accepted

Image transforms not working properly

If I remember correctly, you will see urls similar to this http:\/\/mysite.dev\/cpresources\/404?x=CjvOQxsnA if you have generateTransformsBeforePageLoad as false. It could genuinely be the case that ...
joep's user avatar
  • 610
3 votes
Accepted

Loop through JSON object in Twig from the database

You'll simply need to decode the JSON string. Unfortunately, Twig doesn't ship with a json_decode filter, but there's a plugin. Here's how you'd use it: <ul> {% for block in entry.gridcontrol|...
Mats Mikkel Rummelhoff's user avatar
3 votes

How to skip the first X entries using ElementAPI

It seems that offset doesn't work when pagination is set to true (which is its default value). If you don't need pagination for your results, you can add your offset in criteria and set pagination ...
missmatsuko's user avatar
3 votes

Access Element API JSON in another environment

Brandon answered this in a github issue https://github.com/pixelandtonic/ElementAPI/issues/4 You can do that by setting your endpoint config to an anonymous function: 'my/endpoint/pattern' => ...
Spoeken's user avatar
  • 327
3 votes

Craft 3 Plugin Controller - returnJson() replacement?

I wasn't rtfm'ing hard enough. In the docs for \yii\web\Controller, which is what the \craft\web\Controller class extends (which is what your plugin controllers extend) there is a method asJson(). ...
JamesNZ's user avatar
  • 947
3 votes
Accepted

How to store custom data into a user

There are a whole bunch of ways to do what you want to do. You can add custom fields to user accounts. If you wanted to go with option 2 then you could create a custom text field and write the JSON ...
foamcow's user avatar
  • 2,029
3 votes

Limiting entries object when using as json_encode

As per the docs: Element queries are specialized query builders under the hood, so they support most of the same methods provided by craft\db\Query. ...So, in your case you could use select() to ...
James Smith's user avatar
  • 5,474
3 votes

Jsondecode in element API causing memory issue

For an API that deals with a large amount of data, you want to avoid loading all objects into memory. Bumping up the memory limit is only a stop-gap measure, as you said. A couple of approaches to ...
MoritzLost's user avatar
  • 11.7k
3 votes

How to retrieve (& output via twig) one key pair of json object stored i a database column

If you know there's only one row you're interested in, you can execute the query with .one() instead of .array(), this will give you a single result row as an associative array instead of an array of ...
MoritzLost's user avatar
  • 11.7k
2 votes

Access Element API JSON in another environment

I don't know whether you've seen this answer to another similar question, but it might get you a bit closer: Ajax Post to guestEntries/saveEntries from another domain You could maybe combine what ...
Steve Holland's user avatar
2 votes
Accepted

How to skip the first X entries using ElementAPI

We just released Element API 2.6.0 with added support for the offset criteria param, in combination with paginate => true. (Thanks to @missmatsuko for posting a GitHub issue about it: https://...
Brandon Kelly's user avatar
2 votes

Element API + JSON data in template

I can't think of a clean way to do this. The Element API plugin currently will set JSON headers on the response and return the data JSON encoded, so it's not easy to directly embed in a template. A ...
Brad Bell's user avatar
  • 67.5k
2 votes
Accepted

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

The issue was that curl was, by default, returning the result of the http request to the WebToLead servlet directly, rather than only storing it as $result. This raw HTML response was super-ceding the ...
Aiden Bordner's user avatar
2 votes

Feed Me: Valid JSON file returning as invalid

I think the Json-file in it self is valid (you can always run it through a linter like JsonLint) but the problem lies with the fields. Some items (such as title) are required. I found a more accurate ...
Jan_dh's user avatar
  • 858
2 votes

Querying channel entries hits memory limit

Assuming you're referring to Craft 2, the EntryModels that get returned to a template do have a significant memory overhead attached to them you're probably running into. Doing the math, even bumping ...
Brad Bell's user avatar
  • 67.5k
2 votes
Accepted

Querying channel entries hits memory limit

Read some pages in the craft docs that Brad linked to get to know the basic structure where to place your files Go to Pluginfactory and create a plugin, you only have to check the "Variables" light ...
Robin Schambach's user avatar
2 votes

Use FeedMe with a dynamic URL

There's currently no way to achieve this with Feed Me. A single feed would represent a collection of items to be imported as elements/entries. One method your could consider is setting up a feed for ...
crawf's user avatar
  • 3,562
2 votes
Accepted

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

IMO, the issue is with this line. SetEnv HTTP_ACCEPT text/html,application/xhtml+xml,application/xml,application/json;q=0.9,*/*;q=0.8 With ACCEPT headers set to a fixed value, it's impossible for ...
Hieu Nguyen's user avatar
2 votes

Are there any alternatives to the deprecated Export plugin?

Assuming you want to export to a CSV, I'd recommend trying the Sprout Reports plugin... https://sprout.barrelstrengthdesign.com/craft-plugins/reports
Lindsey D's user avatar
  • 24.1k

Only top scored, non community-wiki answers of a minimum length are eligible