All Questions
Tagged with plugin-elementapi craft3
40 questions
0
votes
1
answer
56
views
Element-api get other entries by id inside a entry.json
I have few entry ids from a plugin(donkeytail), and are arranged in an array,
I need to loop through that array and get title, slug, etc of each entry.
$entry->pins = ["106","122&...
1
vote
0
answers
125
views
Element API relatedTo not working
I'm creating a lazy load/infinite scroll based on the tutorial but I want it to grab entries that are in categories. It doesn't seem to be doing anything with it at all though. It's returning the list ...
1
vote
0
answers
99
views
Join multiple tables in element-api
My problem is the following:
I have a website with products which contains ratings.
I have an element-api endpoint to get the products. I want to sort the products based on the average rating or the ...
2
votes
2
answers
517
views
How to search on multiple (custom) fields using Element API
I am using the Element API to search for entries that match a search query: either the title OR the excerpt should contain the query term. The entry is very simple and has these fields:
-title
-...
0
votes
0
answers
202
views
How to load more entries of a category on that category's page with Element API?
Following up on previous questions of mine: How to use multiple different instances Element API "Load More" button?
I have a website that utilizes the "load More" (button) method ...
1
vote
1
answer
147
views
How to use multiple different instances Element API "Load More" button?
Following up on a previous question of mine:
How to skip the first few entries in a "load more" scenario with Element API?
I have a website that utilizes the "load More" (button) ...
1
vote
1
answer
162
views
How to skip the first few entries in a "load more" scenario with Element API?
I have a website that uses a "load more" button. The process for this button can be found here:
http://craftsnippets.com/articles/infinite-scrolling-and-lazy-loading-with-craft-cms
I made it ...
1
vote
1
answer
900
views
Use GET parameters to query for array of entry IDs
On my client side, I have an array of entry IDs that match with entries in Craft
const myIds = ['230', '249', '256']
I am trying to send that array over to an Element API endpoint and use it in the ...
2
votes
1
answer
228
views
How can I get field's value of entry in other site locale in my element-api endpoint?
I'd like to get a field value in 3 differents locales in the same element-api endpoint but I can't make a request similar to this one : craft.entries.siteId($siteId).id($entryId).one() in twig.
<?...
0
votes
0
answers
320
views
Deprecation Warning: Use the all() function to fetch the query... in PHP
I am getting this warning message:
"Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them. "
It is pointing out ...
0
votes
0
answers
81
views
ElementAPI: How to trigger the Custom service php file when a endpoint is loaded
I am Using Craft 3.3.11 version
I have a php file in
plugin/elementapi/src/services/EapiServices.php
and the same file within
vendor/craftcms/element-api/src/services/EapiServices.php
When ...
4
votes
1
answer
425
views
Using multiple elementTypes in Element API
I am currently trying to create an autocomplete search with the element-api. I need results from two different elementTypes:
Product::class
Entry::class
How do I get results out of both elementTypes ...
2
votes
1
answer
280
views
Pass params to transform function of Transformer class in split Transformer class
I have transformer like down below in the element API.
'transformer' => 'MyTransformerClassName',
Or
'transformer' => new MyTransformerClassName(),
I am going to pass a param like $user ...
2
votes
1
answer
211
views
How to return a hierarchical list of a site's page structure using the ElementAPI
I'm experimenting with using Craft in a headless way and am successfully using the Element API to return all the data required to show individual pages.
However, to be able to show sub navigation and ...
1
vote
2
answers
307
views
Element API - Order results by Category
Is there a way to order the Craft Element-API results by the category title?
I'm just getting the error
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
The "...
1
vote
1
answer
292
views
Element API - Markdown in JSON
I'm a little bit stuck using the Element API. I managed to get my JSON file going pretty easily which was great but I've reached a point where I want to include some formatted copy as it would be ...
1
vote
1
answer
177
views
Element API: How to get entries up to a certain page?
I have a query that is pulling entries from a structure with
elementsPerPage' => 3
If my pagination looks like this:
Page 1:
Entries: A, B, C
Page 2:
Entries: D, E, F
Page 3:
Entries: G, H, I
...
0
votes
1
answer
360
views
How do I fetch all categories under a category group using the Element API?
I am not too familiar with PHP and am just learning the Element API.
How do I turn this craft query into an element api query?
craft.categories.group("brands").level(1).all(),
In categories this is ...
1
vote
1
answer
726
views
Element API — Endpoint has an invalid elementType
I'm trying the Element API for the first time and getting this error message {"error":{"code":404,"message":"Endpoint has an invalid elementType"}}
I cannot for the life of me figure out what I'm ...
1
vote
0
answers
42
views
Query element api (output) via plugin
Is there a way to fetch the content generated by the Element API via a plugin.
For example, if we have created an ingredients/<slug:{slug}>.json endpoint, can the data for a specific page (eg ...
1
vote
0
answers
204
views
element-api: include a collection with mixed entry types, and nested includes
Does anyone know how to include a collection of entries, containing multiple entry-type, in such way that:
1. Each entry type gets transformed by its own custom transformer class (tailord to the ...
1
vote
1
answer
263
views
Element API: Is it possible to ignore/skip an Entry?
I would like to exclude some of my entries, via my own validation inside the Transformer, from the api output.
Is there a possibility to move on to the next Entry without outputing anything? Right ...
2
votes
1
answer
457
views
Element API calling Module that integrates with third-party plugin
This is probably a bit niche but anyone especially au fait with the element api here?
On project X I have a custom module within which I am referencing a service from another plugin (bolden/google-...
2
votes
0
answers
461
views
Group by Date Field in Element API Query
I have a custom field called releaseDate in one of my entry types. I would like to use Element API to get all the distinct years assigned to those entries. I dump all the years for all entries just ...
1
vote
1
answer
179
views
Matrix block Element API call on null error
I get this JSON error when trying to output content of a matrix block called proLinks using the Element API.
Call to a member function all() on null
The code is as follows (I've shortened it and ...
1
vote
0
answers
595
views
Element API SearchQuery to search for value inside child-entries
I currently try to use the Element API to build a search. Unfortunately I'm kind of stuck.
I have a baseEntry, that has a field that references entries (let's call them subEntries) of the section ...
0
votes
0
answers
169
views
Using Embedded Assets Plugin With Element API
When using the Element API, how do you go about using the Embedded Assets plugin?
With a regular asset, in the API transformer you can pull out assets and include them like this:
'transformer' => ...
2
votes
1
answer
2k
views
Craft 3 Element API Authentication/Login
First things first: This is quite similar to this, yet different.
I'm trying to get authentication/login for Element-API for Craft 3 to work. Meaning I would like to restrict access to certain ...
0
votes
2
answers
507
views
Use Imager plugin with Element API?
I'm trying to use the Imager-Craft plugin to make specific image transformations, but cannot figure out how to access Imager within the element-api.php file.
Imager shows plenty of template examples, ...
1
vote
1
answer
348
views
Matrix block fields returning NULL when using MatrixBlock query
$blocks = MatrixBlock::find()->relatedTo($entry)->all();
The above returns the correct blocks but all fields are returned as NULL.
I've read over at GitHub that we need to specify a fieldId ...
1
vote
0
answers
524
views
Element API plugin: searching and working with nested objects
I’m experimenting with the Element API plugin and working with querying the tags of the assets that appear in matrix blocks in a set of entries. Essentially I’m hoping to be able to use a tag in a ...
2
votes
1
answer
1k
views
Element API: Get Matrix Content
So I'm trying to get my Matrix as JSON with the Craft CMS Element API plugin.
<?php
use Craft\elements\Entry;
return [
'endpoints' => [
'api/sites' => [
'...
3
votes
1
answer
981
views
Craft 3 Element API: Query the "parent" entry of a "child" entry with Matrix blocks connected by an 'Entries' field
In a Matrix block field of a "page" entry, I'm using an Entries field to manually select a list of "article" entries to the "page" entry.
When I query an "article" entry, is it possible to query its "...
2
votes
2
answers
836
views
Craft 3: get enabled sites of an entry
I'm looking for a way to list all the enabled sites for a given entry.
I couldn't find some sort of getEnabledSites method that's similar to the available getSupportedSites. The latter only returns ...
1
vote
1
answer
470
views
Get all Categories with getGroupById in Element API plugin - Craft 3
I have an endpoint created and I am getting the groupID but I am unable to get all the categories associated with the group.
This is what I have right now:
$categoriesGroup = Craft::$app->...
3
votes
2
answers
2k
views
Saving asset programatically, eg via API
I'm working on a plugin in Craft 3 that is fetching a file reference (URL) via an API.
I want to fetch the file and save it locally as an Asset. I've tried to do this via Craft::$app->getElements()...
1
vote
0
answers
191
views
Craft 3 Element Api when system status is disabled
Using Craft 3 RC14
System status is set to off
Wondering if anyone has approached the same problem as I did. If there is a way to use element api while the system status is disabled?
I have tried ...
3
votes
1
answer
2k
views
Element API display entries by category
With v2 of the Element API plugin, I'm having issues with working out how to return entries that are in a particular category.
I've got the slug in the API route but can't work out what the query ...
5
votes
3
answers
2k
views
How to render a Twig template in the element-api plugin (v2.5)
I want to render a Twig template in an API endpoint. Specifically I need HTML for the JSON Feed field "content_html".
My attempts until now (inside the transformer function):
$view = Craft::$app->...
4
votes
0
answers
877
views
How to handle Craft 3 events in a plugin? Element API is returning null data
The below refers to Craft 3 and the Element API plugin for Craft 3.
I would like to do something when the Element API plugin fires its onBeforeSendData event, I can see in the controller for element ...