This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Retrieve data via an external API on Drupal 9

Hello everyone,
I'm relatively new to Drupal.
Before asking this question, I looked for my answers on forums and tutorials, without success because I still can't solve my problem.

I have a site developed under drupal 9. On this site, I need to retrieve information (among others: a list of events, users, etc..) from an external API (which is managed with swaggerui )

The API is a Rest API, with an endpoint.
To connect to it, I must already generate a token, and once the token is generated I can retrieve the information.

Example :

Working with custom entities in secondary database

So I came across this article, which outlines how to create custom entities, and custom storage handlers for those entities. What isn't clear, is how to get Drupal to do this for external databases. Here's the scenario. 

I have a Drupal installation that I am building a custom integration for. There is a secondary database setup with it's own relationships and schema. (Not Drupal related). 

Preserving PHP code

Drupal 8 and up don't like users to "do" PHP. That's somewhat understandable, although I feel the dreaded security risk is a tad exaggerated: a bit of basic user management can prevent a lot of harm. So, I for one Do like to have PHP available within Drupal, as it was in olden days - especially in a localhost development environment. Understandably, it was a very sad day when I found out that Twig templates don't accept PHP any more, like the PHP Template system used to do. I badly miss that! 

Superfish automatically expand and stay fixed.

Hello

When I add links to menu items the superfish menu shows expanded on all pages and stays fixed but not on the front page. If I remove the link then it will not expand.

How do I set the value of a custom field in a plugin?

I am able to set the value of a node's title field in a Plugin by overriding the execute method with this code:

public function execute($node = NULL) {
  /** @var \Drupal\node\NodeInterface $node */
  $node->setTitle('My title')->save();
}

Instead of the title field (defined by core), how do I set the value of a custom field (e.g: field_myfield) in a Plugin?

For routes rendering data from third-party API, how to set page title without making an additional request

I have a route /people/{{slugged-full-name}} in place to present a person based on data retrieved from a third-party API. I'd like to set the page title using data from some of the fields retrieved in the initial request to the API (which is handled through one of the controller's dependency injected services).

From my understanding it's no longer possible to dynamically set the title directly through the controller's render array, e.g.,

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions