Drupal Module Development Basics: Create a voteapi module

Create a single vote in a drupal module.

VotingAPI docs are out of date. votingapi_set_vote() has been removed in Drupal 8.

What should I use in its place to programmatically set votes (for instance in a migration)?

use Drupal\votingapi\Entity\Vote;

$vote = Vote::create(['type' => 'vote']); // this comes from /admin/structure/vote-types
$vote->setVotedEntityType('node'); // entity type
$vote->setVotedEntityId($nid); // node id
$vote->setValueType('points'); // this comes from /admin/structure/vote-types
$vote->setValue(1); // the number of points given per vote
$vote->setOwnerId($uid); // the user id of the person who casted the vote
$vote->setCreatedTime($timestamp) // timestamp of when vote was casted (optional)
// it will use the current time if you don't include it


Create a custom display field or sudo field

drupal attach a library to a theme

(function ($) {
    "use strict";
    Drupal.behaviors.ThisIsWhatExactly?? = {
        attach: function (context, settings) {

How do I append a view to the node body in custom module?

How to render a view programmatically and set as node field?

Display-only Pseudo Fields in Drupal 8

Pseudo fields in Drupal 8

Drupal 8 - Override the rendering of node page using hook

Create form with ajax callback.

How To Use AJAX API in Drupal 8? An AJAX HTTP error occurred. HTTP Result Code: 200 Drupal\Core\Form\FormAjaxException: in Drupal\Core\Form\FormBuilder->buildForm() (line 339 of /core/lib/Drupal/Core/Form/FormBuilder.php). controller function use with ajax

How to programmatically give node a rating by user?

Ajax for Like and Dislike using voting API | Drupal

How do I trigger a modal from a template that points to a controller returning an AJAX response

Chapter 4. Drupal Programming Examples

What should I use in Drupal 8 instead of votingapi_set_vote()?

after searching Drupal 8: How to Get Your Star Ratings in Google Search Results