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

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:

Creating a node by code: Where to place the code.

I am trying to create a custom module to createa new node programatically. I believe this short and sweet code snippet will do it.

$node = \Drupal::entityTypeManager()->getStorage('node')->create([
   'type'  => 'page',
   'title' => 'This is the Title',
   'body'  => 'Some text in the body.',
]);
$node->save();
\Drupal::messenger()->addStatus(t('The page has been created.'));

But where in my custom module do I place this code? Should it be a Plugin, a Controller, a Service, or what?

Dynamic Access Control Subscriber Service

I need to insure a user didn't modify a url in their browser to access information he or she is not supposed to have access to. The url paths I'm monitoring is /users/123. "/users/123" is the path to a view with a contextual filter. I want to prevent the user from changing 123 to something else and viewing and editing another user's information. 123 is an id that is in a custom field in their user profile set by an administrator. 

I'm trying to do this with a service as follows:

Pages

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