developer resources
Codebales holds an ever growing number of solutions to problems that we have experienced in our day to day code writing
Selected filter
148
results
Andrew Fletcher
•
If you are like me, almost every view I have will have this filter. So I regularly have the need to set a contextual filter programmatically. However, some won't and will have other contextual filters instead.
You can pass through the $view object the contextual filter params using the setArguments() method. Say you want to pass three node nids to the view to filter the results contextually:
$view->setArguments(['324+613+87']);
Continuing this theme, see the...
Andrew Fletcher
•
Have you come across the following Drupal error message:
Mismatched entity...
Andrew Fletcher
•
Working on a decoupled React / Drupal 9 site.
Aim: Adjust the output of curated...
Andrew Fletcher
•
How to make React calls on a Drupal 9 backend site using the search...
Andrew Fletcher
•
In this instance, I'll check the beginning of the string. I want to focus...
Andrew Fletcher
•
Using the Drupal Poll module and passing via RESTful API - How do you get it working?
The initial set-up
POST: {domain}/mhc_custom/poll?_format=json
Content-type: application/json
Accept: application/json
{
"choice": "1"
}
If you run the above credentials, you will find the following response
{
"message": "The 'restful post mhc_custom_poll_submit' permission is required."
}
Let's have a look at the backend
path: Admin > Configuration > Web services...
Andrew Fletcher
•
This code is from Drupal 9 back-end for a React front-end via REST API.
Working...
Andrew Fletcher
•
For an introduction into setting up RESTful hal+json refer to the set-up...
Andrew Fletcher
•
How to use the Drupal REST API to trigger I've forgot (need to change) my...
Andrew Fletcher
•
To get the X-CSRF token, first, you need to login as a member. Follow the...
Andrew Fletcher
•
In retrieving an image, the primary element required is:
File id or fid;
Query string
Using the element outlined above the query string becomes:
{domain}/file/{fid}/?_format=hal_json
Replacing the following variables:
{domain} ~ your-site.com
{fid} ~ 3214
Becomes:
your-site.com/file/3214?_format=hal_jsonGenerates the following output:
{
"_links":
{
"self":
{
"href": "https://your-site.com/file/3214?_format=hal_json"
},
...
Andrew Fletcher
•
For an introduction into setting up RESTful hal+json refer to the set-up...
Andrew Fletcher
•
For an introduction into setting up RESTful hal+json refer to the set-up...
Andrew Fletcher
•
For an introduction into setting up RESTful hal+json refer to the set-up...
Andrew Fletcher
•
To POST an image is similar to the other posts mentioned on this site....