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
1answer
17 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. ...
0
votes
1answer
13 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 ...
1
vote
1answer
21 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 ...
0
votes
0answers
16 views

Apply search filter in Element API

I have managed to build the search filter structure at the twig, but I get stuck when try to convert this structure in element API, {% if craft.request.getParam('query') %} {% set keyword = craft....
0
votes
0answers
25 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....
1
vote
1answer
32 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 ...
0
votes
0answers
34 views

Element API: How to process the nested entries with different element types of fields within like Entries, Text, Matrix, Redactor

Version: craft 3.3 Result to obtain: Custom Endpoint returning json formatted output Current scenario: Entry level Input from DB which has multiple objects/arrays of data. Each objects/arrays ...
1
vote
1answer
40 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 ...
0
votes
0answers
25 views

Craft search using criteria with related

In the element API following has been defined. $criteria = [ 'section' => $settings['section'], 'limit' => $settings['limit'], 'offset' => $settings['limit'] * ...
1
vote
1answer
17 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
0answers
81 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 ...
1
vote
0answers
28 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-...
1
vote
1answer
31 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 ...
1
vote
1answer
93 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 ...
1
vote
0answers
49 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: '...
0
votes
0answers
22 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 ...
2
votes
0answers
38 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
1answer
39 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 ...
1
vote
1answer
103 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.
1
vote
1answer
30 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' =>...
2
votes
1answer
61 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 ...
0
votes
0answers
9 views

Output category hierarchy in Element API

I am looking to output categories in a level hierarchical format. I have multiple categories, with different levels of categories. Entries can be related to different levels of those categories. ...
1
vote
2answers
86 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 "...
0
votes
0answers
25 views

Element Api: Create list of sites

I'm trying to provide a list of sites in a multisite environment as a JSON Feed for a Vue component. My current solution is to loop through the sites in the template with twig and pass it back to ...
1
vote
1answer
158 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
1answer
40 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 ...
1
vote
1answer
23 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){ ...
0
votes
0answers
34 views

How can i filter on site and locale in the element API

I have multiple sites and locales enabled. How can filter on entries only from a given site and locale? Here's what I have. As you can see I already have a the $site and $locale variables, but I don'...
1
vote
1answer
82 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 ...
0
votes
1answer
62 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 ...
0
votes
0answers
26 views

Send delete event timestamp element api

I have an endpoint that sets a response header when an entry is saved (code below). Is there a similar method I can use when an entry is deleted? 'api/entries.json' => function() { ...
1
vote
1answer
1k 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 ...
1
vote
1answer
63 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 ...
1
vote
1answer
271 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
1answer
144 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 ...
1
vote
0answers
18 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 ...
1
vote
0answers
32 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 ...
0
votes
1answer
50 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-&...
1
vote
1answer
102 views

Get a specific product with Element API, Commerce and Craft 2

How do I get a specific product via Element API? Here's what i have so far 'api/product' => function() { $productId = craft()->request->getRequiredQuery( 'productId' ); return [ ...
1
vote
1answer
31 views

Get last change timestamp in header response

I'll be polling an endpoint created with the element-api plugin which will trigger a concourse build. I need to include a timestamp the last time any entry was changed. So I need something to go in ...
1
vote
0answers
96 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
0answers
30 views

Retrieving Entries by Category & Exclude by Tag

I have an endpoint that I want to retrieve entries by a category, but then exclude entry ids if they have a certain tag. It seems to me that the relatedTo param overrides the id param that says not in ...
1
vote
1answer
89 views

Element api JSON output formatting

I want to output all globals with one endpoint. This is trivial for the most part but I need to have some objects in a specific shape. I'm using a matrix block to handle the content. The main issue ...
1
vote
1answer
119 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 ...
1
vote
1answer
39 views

How I’ll get an entryId based on a given URL?

I want to configure deeplinks for an app and want to set up 'universal links'. Right now I'll send an entry id to the element api to get the right content. But with universal links I didn't have a ...
2
votes
1answer
198 views

Element API throws 404 when not logged into CP

My element API endpoint throws a 404 when I'm logged out of the CP, but works fine when I'm logged in. When logged out it throws a regular 404 with stack trace exactly as any other non-existing url, ...
2
votes
1answer
273 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-...
1
vote
1answer
66 views

Craft update process affecting Element API cache

I have a site A using the Element API plugin to feed content to site B via JSON and handlebars templates. The process is both sites are up to date with content 'x' and it works fine. When I run the ...
1
vote
1answer
110 views

How to reset a multi-value checkbox using EVENT_AFTER_SAVE_ELEMENT in Craft 3?

I'm porting the functionality of an existing plugin from another CMS into Craft 3 through a custom Craft module. The functionality is: When an option from a multi-value checkbox is checked on the "...
2
votes
0answers
229 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
2 3 4 5