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/)%",
&...
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.
5
votes
Accepted
Get Assets in JSON with ElementAPI
Something like the following should work:
// elementapi.php
return [
'endpoints' => [
'assets.json' => [
'paginate' => false,
'elementType' => ...
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 ...
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 ...
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 ...
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",
...
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 ...
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....
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 (...
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 ...
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 ...
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|...
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 ...
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' => ...
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().
...
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 ...
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 ...
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 ...
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 ...
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 ...
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://...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
json × 95plugin-elementapi × 21
templating × 12
plugin-development × 11
plugin-feedme × 10
ajax × 7
craft3 × 6
entries × 6
redactor × 6
plugins × 4
php × 4
javascript × 4
matrix × 3
database × 3
richtext × 3
localization × 2
field × 2
config × 2
cache × 2
image × 2
craft-pro × 2
array × 2
import × 2
channels × 2
table-field × 2