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

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.,

Get content from View?

Using Drupal 9.x and I am trying to get the content from a view where the display is a page and the path is /people/%. The '%' is a reference to a taxonomy term. How do I get the content in this case?

    $view_id = 'person_list';
    $display_id = 'page_3';
    $args = [$term];

    $view = Views::getView($view_id);
    $view->setArguments($args);
    $view->setDisplay($display_id);
    //$view->preExecute();
    $view->execute();
    $count = count( $view->result );
    devel_dump($count);

The above code returns null.

File or document management module

Hi,

In my company many departments have their own forms (PDFs, Words) and many other documents. Each department uploads their documents on their own sections but no one can follow up the updated files and may be another version is uploaded somewhere else. is there a module that can mange this? I want to centralize the documents and make them available only in one place and if a version is updated there will be a text that says last update is on... etc.

Any solutions? 

sort the result of the getQuery on an entityreference field

Hi, I'm interested in sorting the query result on an entityReference field (field_ufficio).
I have done various tests but I have not succeeded.
The code is this 

$nids = $nids->condition('type', 'anagrafica')
  ->condition( 'status',  1 )
  ->sort( 'field_ufficio', 'ASC' )
->execute();

Grouping rows into columns in node

I have a content type "Awards" that has data structured as below:

Pages

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