Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [plugin-elementapi]

Plugin that makes it easy to create a JSON API for your elements, from Pixel & Tonic.

Filter by
Sorted by
Tagged with
0 votes
0 answers
37 views

Element API: Group Categories by Groups

I want to use the Element API to output a hierarchical JSON list of categories grouped by category group. For example: { "groups": [ { "id": 2, &...
kmgdev's user avatar
  • 1,179
2 votes
1 answer
97 views

How to Escape a Query Parameter

Extremely not a PHP developer here but trying to set up a simple API with Element API. I've got the basics working to filter my entry results based off of a query URL parameter: use craft\elements\...
kmgdev's user avatar
  • 1,179
1 vote
1 answer
55 views

How to migrate a selection of users passwords from a Craft 3 to a separate Craft 4?

I'm trying to move a large batch of users from a Craft 3 to a separate Craft 4 websites (only some selected data should be migrated). Element API + FeedMe looks like the right solution for that, as ...
Romain P.'s user avatar
  • 1,852
0 votes
1 answer
45 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&...
Prashant sharma's user avatar
0 votes
0 answers
38 views

Outputting geojson collection with element-api

I am trying to get the element-api to output a valid geojson collection. The way the keys are set in the returned data make me think it isnt possible. To produce a valid string of json i am having ...
joomkit's user avatar
  • 2,024
0 votes
0 answers
83 views

Element-api search with space in query returns zero data

I have an endpoint for searching entries via the element api. 'api/searchtherest.json' => function () { $section_handle = 'openFunding'; $criteria = [ '...
joomkit's user avatar
  • 2,024
1 vote
1 answer
47 views

Jsondecode in element API causing memory issue

I have the element api pulling back 1300 entries. One of the fields is storing geojson data and I had to change the type from text to mediumtext to accommodate some of the data stored. When I moved ...
joomkit's user avatar
  • 2,024
1 vote
0 answers
117 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 ...
Alyssa Tyler's user avatar
1 vote
0 answers
96 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 ...
Mathies Gielen's user avatar
1 vote
1 answer
860 views

Element API: Get Entries Related to Category with Query Parameter

I'm using the Element API Plugin to create an API, with which I want to get entries related to one category, but dynamically with the category set in the Url. What I have so far in the config/element-...
Malte's user avatar
  • 215
2 votes
1 answer
168 views

Element API using the entries field to display related content from a separate section

I've seen similar questions but none seem to help. I have two sections named jobs and jobDescriptions. I'm using the entries field to pull in a description field from the jobDescriptions section to ...
lanceb's user avatar
  • 23
1 vote
2 answers
142 views

Accessing SEOmatic meta via controller action in Element API triggers HTTPForbiddenException

I'm attempting to fetch SEO meta for entries inside of an element API, roughly following the advice in Element API integration Below is the exact code in my element-api.php: <?php use craft\...
cmal's user avatar
  • 815
2 votes
2 answers
462 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 -...
Wouter's user avatar
  • 33
1 vote
1 answer
381 views

Element API, query entries where relationship field ':empty:' AND the same relationship field with specified entry ID

Element API, query entries where relationship field ':empty:' AND the same relationship field with specified entry ID. Can't seem to figure out how to do this without performing two separate queries ...
Bransin's user avatar
  • 117
1 vote
1 answer
36 views

Setting relative path to ElementAPI in PHP

I need a few small bits of data from Craft in a PHP file. It’s a really small task, so I don’t want to delve into writing plugins or anything hardcore. It seemed to me the simplest way to approach it ...
mitrol's user avatar
  • 262
2 votes
1 answer
300 views

Get currentSite.handle in Element API

I need to get the currentSite in Element API. How can this be achieved? Is it as a slug in the endpoint URL? or as a Query param? Here is the current code: <?php use craft\elements\Entry; use ...
nfq's user avatar
  • 23
0 votes
0 answers
197 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 ...
Justin Kendall's user avatar
1 vote
1 answer
127 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) ...
Justin Kendall's user avatar
1 vote
1 answer
152 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 ...
Justin Kendall's user avatar
0 votes
1 answer
151 views

How get entries between mutiple dates, ordered by date?

I'll import (event) entries with feedme in craftcms 2 from an API who I'll can't change. The api gives the startdate off the events in a dateTime object. The allDay events have a date without time. ...
Maarten Heideman's user avatar
1 vote
1 answer
203 views

Retrieve Matrix Field from Related Category in Element API

I have an API endpoint set up for a category group. This currently provides some details of all entries that have been assigned that category (i.e. related entries). That works well for some high ...
theAdhocracy's user avatar
1 vote
1 answer
98 views

Element-api - filter Draft entries by the draft author (not original author)

I have a remote app that enables preview based on your editor craft account. I want to retrieve draft entries that they are working on, but i cant find a way to do this. 'authorId' seems to always be ...
Spotd's user avatar
  • 123
0 votes
0 answers
236 views

Search for category and title in Element API for Jquery Autocomplete

I'm working on the search Autocomplete based on this article, http://craftsnippets.com/articles/search-autocomplete-component-for-craft-cms Besides the title, I want to search within the category too....
Lee's user avatar
  • 139
1 vote
1 answer
308 views

Headless mode/ElementAPI: how to set the frontend's baseUrl in the backend endpoint?

I am having an ongoing confusion in headless mode. Imagine a site with 2 servers: Backend (Craft with element API) on https://backend.site Frontend (vue.js) on https://frontend.site Editors pick ...
Urs's user avatar
  • 639
1 vote
1 answer
777 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 ...
Graham Bewley's user avatar
2 votes
1 answer
215 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. <?...
Elodie Grondin's user avatar
0 votes
0 answers
319 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 ...
Jessica Talzor's user avatar
1 vote
0 answers
126 views

Migrating to Matrix using Feed Me and Element API

How can I use Element API to move my entry fields into a matrix-based content builder? I'm going off the docs found at https://docs.craftcms.com/feed-me/v4/guides/importing-into-matrix.html#setup-your-...
Christopher Kennedy-Nuñez's user avatar
1 vote
1 answer
127 views

Elements API - How to order / limit the output with an asset field of an entry

I recently started using the Elements API and I made up a recipe site as an example project. It's pretty easy to output the recipes as json data. But I now want some more control about the output of ...
io_berlin's user avatar
1 vote
1 answer
324 views

Dynamic Element API

How can we write Element API configuration files to dynamically output JSON payloads in Craft 3.3? The goal is to create a generic function which only needs endpoint definitions to recursively loop ...
Sean O'Brien's user avatar
1 vote
0 answers
368 views

How to get an Entry in structure and all of its children and it's children's children with Element APi?

How do I get all of an entry's children using the Element API? I want to return something like: data: [ title: 'Root Entry' uri: 'root-entry' children: [ { title: '...
kayq's user avatar
  • 77
0 votes
0 answers
79 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 ...
Velan's user avatar
  • 1
4 votes
1 answer
411 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 ...
pepe's user avatar
  • 315
2 votes
1 answer
250 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 ...
apollo's user avatar
  • 63
1 vote
1 answer
412 views

How to pull an entry's SEOmatic meta tags with Element API?

How do I get the meta tags used in SEOmatic for a specific entry and returning it through the Element API? Not sure how the PHP code looks like when using SEOmatic's PHP API.
kayq's user avatar
  • 77
1 vote
1 answer
63 views

Having issues looping through variants for Commerce 2 Products using Element API

I'm currently able to return the first variant using the following: <?php use craft\commerce\elements\Product; use craft\helpers\UrlHelper; return [ 'endpoints' => [ 'products.json' =>...
kamicrafted's user avatar
2 votes
1 answer
204 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 ...
Jim Pannell's user avatar
1 vote
2 answers
299 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 "...
Steve's user avatar
  • 11
1 vote
1 answer
289 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 ...
Moucky's user avatar
  • 85
1 vote
1 answer
165 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 ...
kayq's user avatar
  • 77
1 vote
1 answer
46 views

Array from matrix fields without quotations

I am trying to create an array bodyBlocks by looping through all of my matrix fields called blockTextContent: $bodyBlocks = []; foreach ($entry->getFieldValue('pageBuilder')->all() as $block){ ...
Mark's user avatar
  • 741
2 votes
1 answer
295 views

Logging in to Craft via Vue/Javascript apps

I'm just diving into the world of javascript frameworks (late to the party I know) and can't figure out the missing piece of the authentication puzzle. What is the preferred way to authenticate users ...
dmatthams's user avatar
  • 2,492
0 votes
1 answer
352 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 ...
kayq's user avatar
  • 77
1 vote
1 answer
3k views

Return JSON array without extra square brackets

I'm having difficulties to remove an additional set of square brackets or avoid including them within array. My JavaScript code currently accesses array's object at 0 index and therefore I'd have to ...
Dominik Krulak's user avatar
1 vote
1 answer
132 views

relatedTo - return only entries that have a related entry where a field in the related entry has a value

Trying to figure out if this is possible in 1 step. I want to return locations that have a related entry in the relatedMerchant field, but I'd also want to make sure that a field in the ...
jpea's user avatar
  • 367
1 vote
1 answer
696 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 ...
fbnntt's user avatar
  • 109
1 vote
1 answer
463 views

How can I query entries based on a Matrix Block Type?

I'm using Element API and trying to create a query that returns a list of entries based on if the entry is using a specific Matrix Block Type. I've tried a few different things including a query that ...
Roger Erik Tinch's user avatar
1 vote
0 answers
27 views

Locales with independent language and country

How might we use Craft to manage our locales, keeping our language and country logic independent? The desired scenario: No duplicate language entries: Spanish in Spain would be the same as Spanish in ...
Sean O'Brien's user avatar
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 ...
Cole Henley's user avatar
  • 1,741
0 votes
1 answer
81 views

Element API unable to get all() of matrix field

I'm getting matrix block content from an entry type which works fine for the most part. It's probably clearer to just paste in the code: Current element api code: $relationsData = []; if($entry-&...
Matt Simon's user avatar

1
2 3 4 5